Skip to content

Commit

Permalink
Merge pull request #8 from TripInfoWeb/dev_auth
Browse files Browse the repository at this point in the history
로그인 처리 수정
  • Loading branch information
ssssksss authored Aug 6, 2024
2 parents c2c2f56 + 39ca849 commit 4a41b17
Show file tree
Hide file tree
Showing 14 changed files with 257 additions and 91 deletions.
110 changes: 110 additions & 0 deletions public/images/auth/solitour-auth-intro-image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/lottie/solitour-auth-intro-image.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion public/lottie/solitour-mettings-intro-image1.json

This file was deleted.

1 change: 1 addition & 0 deletions public/lottie/solitour_gathering_animation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"nm":"Main Scene","ddd":0,"h":282,"w":423,"meta":{"g":"@lottiefiles/creator 1.16.0"},"layers":[{"ty":4,"nm":"Shape Layer - SVG","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[0,-0.5]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[],"ind":1},{"ty":0,"nm":"Nested Scene 1","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[102,204]},"s":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[20,14],"t":0},{"s":[100,100],"t":52}]},"sk":{"a":0,"k":0},"p":{"a":1,"k":[{"o":{"x":0,"y":0},"i":{"x":0.36,"y":1},"s":[211.5,241],"t":0},{"s":[63.5,95],"t":52}]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[10],"t":0},{"s":[100],"t":52}]}},"w":500,"h":500,"refId":"precomp_newScene_414d3be5-af8f-4882-8fbd-08b6bc630467_a14c2d36-45f2-459b-8aad-7d2f0c4034da","ind":2},{"ty":0,"nm":"Nested Scene 2","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[415,187]},"s":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[10,10],"t":0},{"s":[100,100],"t":52}]},"sk":{"a":0,"k":0},"p":{"a":1,"k":[{"o":{"x":0,"y":0},"i":{"x":0.36,"y":1},"s":[211.5,241],"t":0},{"s":[376.5,78],"t":52}]},"r":{"a":0,"k":1},"sa":{"a":0,"k":0},"o":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[10],"t":0},{"s":[100],"t":52}]}},"w":500,"h":500,"refId":"precomp_newScene_d6fab9dd-59a9-43a0-b481-a5c3154f9311_798b71c6-4ddb-4acc-b0c5-d0c73448a0ae","ind":3}],"v":"5.7.0","fr":30,"op":60,"ip":0,"assets":[{"nm":"Nested Scene 1","id":"precomp_newScene_414d3be5-af8f-4882-8fbd-08b6bc630467_a14c2d36-45f2-459b-8aad-7d2f0c4034da","layers":[{"ty":4,"nm":"Group 75","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[38.5,108.5]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"gr","bm":0,"hd":false,"nm":"Group 75","it":[{"ty":"sh","bm":0,"hd":false,"nm":"Path 60","d":1,"ks":{"a":0,"k":{"c":true,"i":[[0,0],[0.0835999999999899,-0.2237999999999971],[0,0],[0,0],[0.21739999999999782,-0.0992999999999995],[0,0],[0,0],[0.2237999999999971,0.08420000000000272],[0,0],[0,0],[0.09890000000000043,0.217800000000004],[0,0],[0,0],[-0.0835000000000008,0.2237999999999971],[0,0],[0,0],[-0.2173000000000016,0.0992999999999995],[0,0],[0,0],[-0.22390000000000043,-0.08420000000000272],[0,0],[0,0],[-0.09900000000000375,-0.217800000000004],[0,0],[0,0]],"o":[[0.09890000000000043,-0.217800000000004],[0,0],[0,0],[0.2237999999999971,-0.08420000000000272],[0,0],[0,0],[0.21739999999999782,0.0992999999999995],[0,0],[0,0],[0.0835999999999899,0.2237999999999971],[0,0],[0,0],[-0.09900000000000375,0.217800000000004],[0,0],[0,0],[-0.22390000000000043,0.08420000000000272],[0,0],[0,0],[-0.2173000000000016,-0.0992999999999995],[0,0],[0,0],[-0.0835000000000008,-0.2237999999999971],[0,0],[0,0],[0,0]],"v":[[65.9972,51.1103],[66.3405,51.2515],[64.4513,56.3122],[69.5132,54.4116],[69.6559,54.7538],[64.7354,56.9999],[69.6559,59.2462],[69.5132,59.5884],[64.4513,57.6878],[66.3405,62.7485],[65.9972,62.8897],[63.7656,57.9727],[61.5341,62.8897],[61.1907,62.7485],[63.08,57.6878],[58.0181,59.5884],[57.8753,59.2462],[62.7958,56.9999],[57.8753,54.7538],[58.0181,54.4116],[63.08,56.3122],[61.1907,51.2515],[61.5341,51.1103],[63.7656,56.0273],[65.9972,51.1103]]}}},{"ty":"st","bm":0,"hd":false,"nm":"Stroke","lc":1,"lj":1,"ml":4,"o":{"a":0,"k":100},"w":{"a":0,"k":1},"c":{"a":0,"k":[0.9843,0.6784,0.6784]}},{"ty":"tr","a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}}]}],"ind":1},{"ty":4,"nm":"Group 76","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[83.5,175.5]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[122,284]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"gr","bm":0,"hd":false,"nm":"Group 76","it":[{"ty":"sh","bm":0,"hd":false,"nm":"Path 61","d":1,"ks":{"a":0,"k":{"c":true,"i":[[0,0],[0.0835999999999899,-0.2230000000000132],[0,0],[0,0],[0.21739999999999782,-0.09999999999999432],[0,0],[0,0],[0.2237999999999971,0.08500000000000796],[0,0],[0,0],[0.09890000000000043,0.21700000000001296],[0,0],[0,0],[-0.0835000000000008,0.2230000000000132],[0,0],[0,0],[-0.2172999999999945,0.09999999999999432],[0,0],[0,0],[-0.22390000000000043,-0.08500000000000796],[0,0],[0,0],[-0.09899999999998954,-0.21700000000001296],[0,0],[0,0]],"o":[[0.09890000000000043,-0.21700000000001296],[0,0],[0,0],[0.2237999999999971,-0.08500000000000796],[0,0],[0,0],[0.21739999999999782,0.09999999999999432],[0,0],[0,0],[0.0835999999999899,0.2230000000000132],[0,0],[0,0],[-0.09899999999998954,0.21700000000001296],[0,0],[0,0],[-0.22390000000000043,0.08500000000000796],[0,0],[0,0],[-0.2172999999999945,-0.09999999999999432],[0,0],[0,0],[-0.0835000000000008,-0.2230000000000132],[0,0],[0,0],[0,0]],"v":[[85.9972,169.11],[86.3405,169.251],[84.4513,174.312],[89.5132,172.412],[89.6559,172.754],[84.7354,175],[89.6559,177.246],[89.5132,177.588],[84.4513,175.688],[86.3405,180.749],[85.9972,180.89],[83.7656,175.973],[81.5341,180.89],[81.1907,180.749],[83.08,175.688],[78.0181,177.588],[77.8753,177.246],[82.7958,175],[77.8753,172.754],[78.0181,172.412],[83.08,174.312],[81.1907,169.251],[81.5341,169.11],[83.7656,174.027],[85.9972,169.11]]}}},{"ty":"st","bm":0,"hd":false,"nm":"Stroke","lc":1,"lj":1,"ml":4,"o":{"a":0,"k":100},"w":{"a":0,"k":1},"c":{"a":0,"k":[0.9333,0.7804,0.5451]}},{"ty":"tr","a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}}]}],"ind":2},{"ty":4,"nm":"Group 77","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[101.5,16.5]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[140,125]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"gr","bm":0,"hd":false,"nm":"Group 77","it":[{"ty":"sh","bm":0,"hd":false,"nm":"Path 62","d":1,"ks":{"a":0,"k":{"c":true,"i":[[0,0],[0.08300000000001262,-0.22380000000000067],[0,0],[0,0],[0.21699999999999875,-0.0992999999999995],[0,0],[0,0],[0.22399999999998954,0.08419999999999916],[0,0],[0,0],[0.09900000000000375,0.21780000000000044],[0,0],[0,0],[-0.0835000000000008,0.22380000000000067],[0,0],[0,0],[-0.2172999999999945,0.0992999999999995],[0,0],[0,0],[-0.22390000000000043,-0.08419999999999916],[0,0],[0,0],[-0.09899999999998954,-0.2177699999999998],[0,0],[0,0]],"o":[[0.09900000000000375,-0.2177699999999998],[0,0],[0,0],[0.22399999999998954,-0.08419999999999916],[0,0],[0,0],[0.21699999999999875,0.0992999999999995],[0,0],[0,0],[0.08300000000001262,0.22380000000000067],[0,0],[0,0],[-0.09899999999998954,0.21780000000000044],[0,0],[0,0],[-0.22390000000000043,0.08419999999999916],[0,0],[0,0],[-0.2172999999999945,-0.0992999999999995],[0,0],[0,0],[-0.0835000000000008,-0.22380000000000067],[0,0],[0,0],[0,0]],"v":[[103.997,10.1103],[104.341,10.2515],[102.451,15.3122],[107.513,13.4116],[107.656,13.7538],[102.735,15.9999],[107.656,18.2462],[107.513,18.5884],[102.451,16.6878],[104.341,21.7485],[103.997,21.8897],[101.766,16.9727],[99.5341,21.8897],[99.1907,21.7485],[101.08,16.6878],[96.0181,18.5884],[95.8753,18.2462],[100.796,15.9999],[95.8753,13.7538],[96.0181,13.4116],[101.08,15.3122],[99.1907,10.2515],[99.5341,10.1103],[101.766,15.0273],[103.997,10.1103]]}}},{"ty":"st","bm":0,"hd":false,"nm":"Stroke","lc":1,"lj":1,"ml":4,"o":{"a":0,"k":100},"w":{"a":0,"k":1},"c":{"a":0,"k":[0.9333,0.7804,0.5451]}},{"ty":"tr","a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}}]}],"ind":3},{"ty":4,"nm":"Group 79","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[38.5,108.5]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"gr","bm":0,"hd":false,"nm":"Group 79","it":[{"ty":"sh","bm":0,"hd":false,"nm":"Path 64","d":1,"ks":{"a":0,"k":{"c":false,"i":[[0,0],[-6.551400000000001,5.396000000000015],[0,0],[-5.671000000000003,5.085000000000008],[0,0],[-6.0563,6.635999999999996]],"o":[[0,0],[6.298399999999997,-5.187999999999988],[0,0],[5.670199999999994,-5.084000000000003],[0,0],[0,0]],"v":[[19.8469,136.649],[25.2767,141.523],[30.4676,144.22],[35.904,146.964],[41.34,149.709],[48.5942,151.137]]}}},{"ty":"st","bm":0,"hd":false,"nm":"Stroke","lc":2,"lj":2,"ml":4,"o":{"a":0,"k":100},"w":{"a":0,"k":2},"c":{"a":0,"k":[0.5843,0.6,0.9804]}},{"ty":"tr","a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}}]}],"ind":4},{"ty":4,"nm":"Group 80","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[38.5,108.5]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"gr","bm":0,"hd":false,"nm":"Group 80","it":[{"ty":"sh","bm":0,"hd":false,"nm":"Path 65","d":1,"ks":{"a":0,"k":{"c":false,"i":[[0,0],[-4.610100000000003,0.6796000000000006],[0,0],[-4.099899999999998,0.775500000000001],[0,0],[-4.6967,1.3744999999999976]],"o":[[0,0],[4.432900000000004,-0.6528999999999989],[0,0],[4.100300000000004,-0.775699999999997],[0,0],[0,0]],"v":[[51.7017,16.4995],[53.058,20.1699],[54.8734,22.7899],[56.7949,25.4976],[58.7165,28.205],[61.8701,30.8063]]}}},{"ty":"st","bm":0,"hd":false,"nm":"Stroke","lc":2,"lj":2,"ml":4,"o":{"a":0,"k":100},"w":{"a":0,"k":1},"c":{"a":0,"k":[0.3882,0.7451,1]}},{"ty":"tr","a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}}]}],"ind":5}]},{"nm":"Nested Scene 2","id":"precomp_newScene_d6fab9dd-59a9-43a0-b481-a5c3154f9311_798b71c6-4ddb-4acc-b0c5-d0c73448a0ae","layers":[{"ty":4,"nm":"Group 78","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[345.5,16.5]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[384,125]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"gr","bm":0,"hd":false,"nm":"Group 78","it":[{"ty":"sh","bm":0,"hd":false,"nm":"Path 63","d":1,"ks":{"a":0,"k":{"c":true,"i":[[0,0],[0.08299999999996999,-0.22380000000000067],[0,0],[0,0],[0.21699999999998454,-0.0992999999999995],[0,0],[0,0],[0.22400000000004638,0.08419999999999916],[0,0],[0,0],[0.09899999999998954,0.21780000000000044],[0,0],[0,0],[-0.08399999999994634,0.22380000000000067],[0,0],[0,0],[-0.21699999999998454,0.0992999999999995],[0,0],[0,0],[-0.22399999999998954,-0.08419999999999916],[0,0],[0,0],[-0.09899999999998954,-0.2177699999999998],[0,0],[0,0]],"o":[[0.09899999999998954,-0.2177699999999998],[0,0],[0,0],[0.22400000000004638,-0.08419999999999916],[0,0],[0,0],[0.21699999999998454,0.0992999999999995],[0,0],[0,0],[0.08299999999996999,0.22380000000000067],[0,0],[0,0],[-0.09899999999998954,0.21780000000000044],[0,0],[0,0],[-0.22399999999998954,0.08419999999999916],[0,0],[0,0],[-0.21699999999998454,-0.0992999999999995],[0,0],[0,0],[-0.08399999999994634,-0.22380000000000067],[0,0],[0,0],[0,0]],"v":[[347.997,10.1103],[348.341,10.2515],[346.451,15.3122],[351.513,13.4116],[351.656,13.7538],[346.735,15.9999],[351.656,18.2462],[351.513,18.5884],[346.451,16.6878],[348.341,21.7485],[347.997,21.8897],[345.766,16.9727],[343.534,21.8897],[343.191,21.7485],[345.08,16.6878],[340.018,18.5884],[339.875,18.2462],[344.796,15.9999],[339.875,13.7538],[340.018,13.4116],[345.08,15.3122],[343.191,10.2515],[343.534,10.1103],[345.766,15.0273],[347.997,10.1103]]}}},{"ty":"st","bm":0,"hd":false,"nm":"Stroke","lc":1,"lj":1,"ml":4,"o":{"a":0,"k":100},"w":{"a":0,"k":1},"c":{"a":0,"k":[0.9843,0.6784,0.6784]}},{"ty":"tr","a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}}]}],"ind":1},{"ty":4,"nm":"Group 81","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[38.5,108.5]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"gr","bm":0,"hd":false,"nm":"Group 81","it":[{"ty":"sh","bm":0,"hd":false,"nm":"Path 66","d":1,"ks":{"a":0,"k":{"c":false,"i":[[0,0],[7.331999999999994,3.6993199999999993],[0,0],[6.44500000000005,3.6205000000000016],[0,0],[7.166999999999973,5.086600000000001]],"o":[[0,0],[-7.050999999999988,-3.5559800000000004],[0,0],[-6.444999999999993,-3.620799999999999],[0,0],[0,0]],"v":[[397.951,1],[394.077,7.38848],[389.908,11.5103],[385.525,15.7464],[381.142,19.9822],[374.766,23.3749]]}}},{"ty":"st","bm":0,"hd":false,"nm":"Stroke","lc":2,"lj":2,"ml":4,"o":{"a":0,"k":100},"w":{"a":0,"k":2},"c":{"a":0,"k":[0.5529,0.8196,0.9765]}},{"ty":"tr","a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}}]}],"ind":2},{"ty":4,"nm":"Group 82","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[398.5,143.5]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[437,252]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"gr","bm":0,"hd":false,"nm":"Group 82","it":[{"ty":"sh","bm":0,"hd":false,"nm":"Path 67","d":1,"ks":{"a":0,"k":{"c":false,"i":[[0,0],[-5.90500000000003,3.556999999999988],[4.5919999999999845,-2.759999999999991],[-6.8729999999999905,-4.340000000000003],[6.834000000000003,-3.209000000000003],[11.024000000000001,29.25999999999999]],"o":[[0,0],[5.409999999999968,-3.2580000000000098],[-2.3570000000000277,1.4170000000000016],[14.365999999999985,7.9339999999999975],[-7.092999999999961,4.009999999999991],[0,0]],"v":[[383.766,147.846],[396.908,155.292],[393.172,139.733],[398.01,151.006],[400.876,135.209],[411.195,132]]}}},{"ty":"st","bm":0,"hd":false,"nm":"Stroke","lc":2,"lj":2,"ml":4,"o":{"a":0,"k":100},"w":{"a":0,"k":2},"c":{"a":0,"k":[0.9843,0.6784,0.6784]}},{"ty":"tr","a":{"a":0,"k":[398.5,143.5]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[398.5,143.5]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}}]}],"ind":3}]}]}
44 changes: 44 additions & 0 deletions src/app/api/auth/kakao/getToken/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { NextRequest, NextResponse } from "next/server";

export async function GET(request: NextRequest) {
try {
// Query string 파싱
const url = new URL(request.url);
const code = url.searchParams.get("code");

// 백엔드에 액세스 토큰 재요청
const backendResponse = await fetch(
`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/auth/oauth2/login?type=kakao&redirectUrl=${process.env.NEXT_PUBLIC_KAKAO_REDIRECT_URL}&code=${code}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
cache: "no-store",
credentials: "include",
},
);

const result = new NextResponse(
backendResponse.status == 200 ? "성공" : "실패",
{
status: backendResponse.status,
headers: { "Content-Type": "application/json" },
},
);

if (backendResponse.status == 200) {
const cookies = backendResponse.headers.get("set-cookie");
if (cookies) {
// 받은 쿠키를 파싱하여 설정
cookies.split(",").forEach((cookie) => {
result.headers.append("Set-Cookie", cookie.trim());
});
}
}

return result;
} catch (error) {
return new NextResponse("서버 에러", { status: 500 });
}
}
22 changes: 13 additions & 9 deletions src/app/api/auth/kakao/route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { NextResponse } from "next/server";

export function GET() {
const kakaoAuthUrl = `https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=${process.env.KAKAO_REST_API_KEY}&redirect_uri=${process.env.NEXT_PUBLIC_KAKAO_REDIRECT_URL}`;
if (
!process.env.KAKAO_REST_API_KEY ||
!process.env.NEXT_PUBLIC_KAKAO_REDIRECT_URL
) {
return new Response("Environment variables are not set correctly", {
status: 500,
});
try {
const clientId = process.env.KAKAO_REST_API_KEY;
const redirectUri = process.env.NEXT_PUBLIC_KAKAO_REDIRECT_URL;
const timestamp = new Date().toISOString(); // Get the current timestamp in ISO format

if (!clientId || !redirectUri) {
return NextResponse.redirect("/auth/signin");
}
return NextResponse.redirect(kakaoAuthUrl);

const kakaoAuthUrl = `https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=${clientId}&redirect_uri=${redirectUri}&timestamp=${timestamp}`;
return NextResponse.redirect(kakaoAuthUrl);
} catch (error) {
return NextResponse.redirect("/auth/signin");
}
}
49 changes: 29 additions & 20 deletions src/app/api/auth/user/route.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
import { cookies } from "next/headers";
import { NextRequest, NextResponse } from "next/server";

export async function GET(request: NextRequest) {
try {
const access_cookie = request.cookies.get("access_token");
if (!access_cookie) {
const refresh_cookie = request.cookies.get("refresh_token");
if (!refresh_cookie) {
return new NextResponse("불필요한 요청", { status: 400 });
}
return new NextResponse("Access token not found", { status: 401 });
const access_cookie = request.cookies.get("access_token");
if (!access_cookie) {
const refresh_cookie = request.cookies.get("refresh_token");
if (!refresh_cookie) {
// 리프레시 토큰이 없으므로 요청 중단
return new NextResponse("Refresh token not found", { status: 403 });
}
// 사용자 정보 조회 API
const response = await fetch(`${process.env.BACKEND_URL}/api/users/info`, {
method: "GET",
headers: {
Cookie: `${access_cookie?.name}=${access_cookie?.value}`,
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
},
});
// 리프레시 토큰으로 재발급 받아 재요청 보내기 위한 응답
return new NextResponse("Refresh token not found", { status: 401 });
}

// 사용자 정보 조회 API
const response = await fetch(`${process.env.BACKEND_URL}/api/users/info`, {
method: "GET",
headers: {
Cookie: `${access_cookie?.name}=${access_cookie?.value}`,
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
},
cache: "no-store",
});

if (response.status === 200) {
const data = await response.json();
return new NextResponse(JSON.stringify(data), {
status: 200,
headers: { "Content-Type": "application/json" },
});
} catch (error) {
return new NextResponse("Internal Server Error", { status: 500 });
}

cookies().delete("access_token");
cookies().delete("refresh_token");
return new NextResponse("서버 에러", {
status: 500,
});
}
2 changes: 1 addition & 1 deletion src/app/service/banner/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface PageProps {
// 서버 사이드에서 데이터 패칭
async function fetchBannerList(): Promise<Banner[]> {
const response = await fetch(`${process.env.BACKEND_URL}/api/banner`, {
cache: "no-cache"
cache: "default"
});

if (!response.ok) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Auth/AuthLoading.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import LottieAirplane from "@/../public/lottie/loading-airplane.json";
import LottieComponent from "../common/Loader/lottie/LottieComponent";
import LottieComponent from "../common/lottie/LottieComponent";

const AuthLoading = () => {
return (
Expand Down
Loading

0 comments on commit 4a41b17

Please sign in to comment.