From 53f45cba2a1cdab01e407a3f4ca38bb898e8bcff Mon Sep 17 00:00:00 2001 From: Seungmin Nam Date: Sat, 20 Jun 2026 21:57:43 +0000 Subject: [PATCH 1/3] feat(be): redirect to frontend after Kakao OAuth login --- .../apps/client/src/auth/auth.controller.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/backend/apps/client/src/auth/auth.controller.ts b/apps/backend/apps/client/src/auth/auth.controller.ts index 14cb376a19..2201f45e57 100644 --- a/apps/backend/apps/client/src/auth/auth.controller.ts +++ b/apps/backend/apps/client/src/auth/auth.controller.ts @@ -11,6 +11,7 @@ import { Param, ParseEnumPipe } from '@nestjs/common' +import { ConfigService } from '@nestjs/config' import { AuthGuard } from '@nestjs/passport' import { Provider } from '@prisma/client' import { Request, Response } from 'express' @@ -27,7 +28,10 @@ import type { GithubUser, KakaoUser } from './interface/social-user.interface' @Controller('auth') export class AuthController { - constructor(private readonly authService: AuthService) {} + constructor( + private readonly authService: AuthService, + private readonly configService: ConfigService + ) {} setJwtResponse = (res: Response, jwtTokens: JwtTokens) => { res.setHeader('authorization', `Bearer ${jwtTokens.accessToken}`) @@ -158,15 +162,18 @@ export class AuthController { @AuthNotNeededIfPublic() @Get('kakao-callback') @UseGuards(AuthGuard('kakao')) - async kakaoLogin( - @Res({ passthrough: true }) res: Response, - @Req() req: Request - ) { + async kakaoLogin(@Res() res: Response, @Req() req: Request) { const kakaoUser = req.user as KakaoUser const result = await this.authService.kakaoLogin(kakaoUser) + const frontendUrl = this.configService.getOrThrow('FRONTEND_URL') - if ('oauthToken' in result) return result + if ('oauthToken' in result) { + return res.redirect( + `${frontendUrl}/login?modal=social-unlinked&oauthToken=${result.oauthToken}` + ) + } this.setJwtResponse(res, result.jwtTokens) + return res.redirect(`${frontendUrl}/`) } } From 6c36fe285aa07f5f16b8bf2c0a34c66bcdb30a65 Mon Sep 17 00:00:00 2001 From: Seungmin Nam Date: Sat, 20 Jun 2026 21:59:27 +0000 Subject: [PATCH 2/3] feat(be): add FRONTEND_URL environment variable for local development --- .envrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.envrc b/.envrc index b0ae683268..77d8644766 100644 --- a/.envrc +++ b/.envrc @@ -1,3 +1,6 @@ +### Frontend ### +export FRONTEND_URL="http://localhost:5525" + ### MinIO ### export MINIO_ENDPOINT_URL="http://127.0.0.1:9000" export MEDIA_BUCKET_NAME="codedang-media" From c3528c39e1090b4996e03e3e626613927f1c3a27 Mon Sep 17 00:00:00 2001 From: Seungmin Nam Date: Sat, 20 Jun 2026 22:04:45 +0000 Subject: [PATCH 3/3] fix(be): import ConfigService in AuthController tests --- apps/backend/apps/client/src/auth/auth.controller.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/backend/apps/client/src/auth/auth.controller.spec.ts b/apps/backend/apps/client/src/auth/auth.controller.spec.ts index eb86acb805..b6d6f80ba1 100644 --- a/apps/backend/apps/client/src/auth/auth.controller.spec.ts +++ b/apps/backend/apps/client/src/auth/auth.controller.spec.ts @@ -1,6 +1,6 @@ +import { ConfigService } from '@nestjs/config' import { Test, type TestingModule } from '@nestjs/testing' import { expect } from 'chai' -import { UserService } from '@client/user/user.service' import { AuthController } from './auth.controller' import { AuthService } from './auth.service' @@ -12,7 +12,7 @@ describe('AuthController', () => { controllers: [AuthController], providers: [ { provide: AuthService, useValue: {} }, - { provide: UserService, useValue: {} } + { provide: ConfigService, useValue: {} } ] }).compile() controller = module.get(AuthController)