-
Notifications
You must be signed in to change notification settings - Fork 2
Feat: 소셜로그인 API연동 #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import { NextRequest, NextResponse } from "next/server"; | ||
| import { createPublicAuthServerAxios } from "@/lib/api/server"; | ||
| import { AUTH_ENDPOINT } from "@/lib/api/constants"; | ||
|
|
||
| export async function POST(request: NextRequest) { | ||
| try { | ||
|
|
@@ -9,13 +10,25 @@ export async function POST(request: NextRequest) { | |
| // 로컬 게이트웨이(localhost:8099)를 통해 /das/**로 라우팅됩니다 | ||
| // multipart/form-data로 전송 | ||
| const serverAxios = createPublicAuthServerAxios(); | ||
| const response = await serverAxios.post("/das/api/auth/signup", formData, { | ||
| const response = await serverAxios.post(`${AUTH_ENDPOINT}/signup`, formData, { | ||
| headers: { | ||
| "Content-Type": "multipart/form-data", | ||
| }, | ||
| }); | ||
|
|
||
| return NextResponse.json(response.data); | ||
| const nextResponse = NextResponse.json(response.data); | ||
|
|
||
| const cookies = response.headers["set-cookie"]; | ||
| if (cookies) { | ||
| if (Array.isArray(cookies)) { | ||
| cookies.forEach((cookie) => nextResponse.headers.append("Set-Cookie", cookie)); | ||
| } else { | ||
| nextResponse.headers.set("Set-Cookie", cookies); | ||
| } | ||
| } | ||
|
Comment on lines
+21
to
+28
|
||
|
|
||
| return nextResponse; | ||
|
|
||
| } catch (error: unknown) { | ||
| console.error("회원가입 API 에러:", error); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -83,9 +83,9 @@ export function selectGatewayUrl(path: string): string { | |||||||||||||
| * 클라이언트 환경 변수를 사용할 수 없으므로 별도 함수 제공 | ||||||||||||||
| */ | ||||||||||||||
| export function selectServerGatewayUrl(path: string): string { | ||||||||||||||
| const localUrl = process.env.GATEWAY_LOCAL_URL; | ||||||||||||||
| const devUrl = process.env.GATEWAY_DEV_URL; | ||||||||||||||
| const useLocalFor = process.env.USE_LOCAL_GATEWAY_FOR || ""; | ||||||||||||||
| const localUrl = process.env.NEXT_PUBLIC_GATEWAY_LOCAL_URL; | ||||||||||||||
| const devUrl = process.env.NEXT_PUBLIC_GATEWAY_DEV_URL; | ||||||||||||||
| const useLocalFor = process.env.NEXT_PUBLIC_USE_LOCAL_GATEWAY_FOR || ""; | ||||||||||||||
|
Comment on lines
+86
to
+88
|
||||||||||||||
| const localUrl = process.env.NEXT_PUBLIC_GATEWAY_LOCAL_URL; | |
| const devUrl = process.env.NEXT_PUBLIC_GATEWAY_DEV_URL; | |
| const useLocalFor = process.env.NEXT_PUBLIC_USE_LOCAL_GATEWAY_FOR || ""; | |
| const localUrl = process.env.GATEWAY_LOCAL_URL; | |
| const devUrl = process.env.GATEWAY_DEV_URL; | |
| const useLocalFor = process.env.USE_LOCAL_GATEWAY_FOR || ""; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |||||
| * 소셜 로그인/회원가입 유틸리티 | ||||||
| */ | ||||||
|
|
||||||
| import { selectGatewayUrl } from "../api/gateway-selector"; | ||||||
|
|
||||||
| export type SocialProvider = "google" | "kakao" | "naver"; | ||||||
|
|
||||||
| export interface SocialAuthResponse { | ||||||
|
|
@@ -28,8 +30,10 @@ export function initiateSocialLogin(provider: SocialProvider): void { | |||||
| const currentUrl = window.location.href; | ||||||
| sessionStorage.setItem("social_login_return_url", currentUrl); | ||||||
|
|
||||||
| const gateWayUrl = selectGatewayUrl("/das"); | ||||||
|
||||||
|
|
||||||
| // 로컬 게이트웨이를 통해 Auth Server의 OAuth2 엔드포인트로 이동 | ||||||
| const authUrl = `http://localhost:8099/das/oauth2/authorization/${provider}`; | ||||||
| const authUrl = `http://${gateWayUrl}/das/oauth2/authorization/${provider}`; | ||||||
|
||||||
| const authUrl = `http://${gateWayUrl}/das/oauth2/authorization/${provider}`; | |
| const authUrl = `${gateWayUrl}/das/oauth2/authorization/${provider}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Console.log statement left in production code. Debug logging should be removed or replaced with a proper logging mechanism before merging to production.