Skip to content

Commit

Permalink
fix/#39/쿠키 설정 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
gwgw123 committed Dec 23, 2024
1 parent 1f347df commit 181fbae
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/auth/jwt/jwt.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class JwtGuard implements CanActivate {

// access 토큰 재발급 및 쿠키에 담기
const newAccessToken = this.NewAccessToken(userId);
this.setAccessTokenCookie(request, newAccessToken);
this.setAccessTokenCookie(context, newAccessToken);

const user = await this.usersService.getUser(userId);
if (!user) throw new UnauthorizedException('User not found');
Expand All @@ -89,8 +89,12 @@ export class JwtGuard implements CanActivate {
}

// access 토큰을 쿠키에 설정
private setAccessTokenCookie(request: Request, accessToken: string): void {
request.res?.cookie('accessToken', accessToken, {
private setAccessTokenCookie(
context: ExecutionContext,
accessToken: string,
): void {
const response = context.switchToHttp().getResponse();
response.cookie('accessToken', accessToken, {
httpOnly: true,
secure: true,
domain: this.configService.get<string>('COOKIE_DOMAIN'),
Expand Down

0 comments on commit 181fbae

Please sign in to comment.