Skip to content

Commit

Permalink
Merge pull request #262 from depromeet/feature/#255
Browse files Browse the repository at this point in the history
코드 원복
  • Loading branch information
YOOJS1205 authored Feb 12, 2024
2 parents 3f33f1a + 20b5fbc commit 152778f
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,17 @@ export async function middleware(request: NextRequest) {
return response;
}

const provider = request.nextUrl.searchParams.get('type');
// NOTE: 카카오 로그인 > 로그인 api 호출 > 토큰 저장 후 메인페이지 이동
if (request.nextUrl.pathname === '/auth') {
const body = await request.json();

const provider = request.nextUrl.searchParams.get('type');
if (request.nextUrl.pathname === '/auth' && provider === 'kakao') {
const code = request.nextUrl.searchParams.get('code');
const id_token = body.id_token;
const redirect_uri =
process.env.NODE_ENV === 'production'
? `${process.env.NEXT_PUBLIC_SITE_DOMAIN}/auth?type=${provider}`
: `${process.env.NEXT_PUBLIC_LOCAL_DOMAIN}/auth?type=${provider}`;

const res = await fetch(
`${process.env.API_BASE_URL}/api/v1/auth/login?code=${
provider === 'kakao' ? code : id_token
}&provider=${provider}&redirect_uri=${redirect_uri}`,
`${process.env.API_BASE_URL}/api/v1/auth/login?code=${code}&provider=${provider}&redirect_uri=${redirect_uri}`,
);

const responseData = await res.json();
Expand Down

0 comments on commit 152778f

Please sign in to comment.