Skip to content

Commit

Permalink
fix: cors, same site 구성
Browse files Browse the repository at this point in the history
  • Loading branch information
argon1025 committed Feb 12, 2024
1 parent 64bf03a commit 118fd5e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/library/jwt-utility/jwt-utility.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export class JwtUtilityService implements IJwtUtilityService.Base {

private readonly COOKIE_DOMAIN = this.configService.getOrThrow<string>('COOKIE_DOMAIN');

private readonly REFRESH_TOKEN_EXPIRATION_TIME = this.configService.getOrThrow<number>(
'REFRESH_TOKEN_EXPIRATION_TIME',
);
private readonly REFRESH_TOKEN_EXPIRATION_TIME = this.configService.getOrThrow<number>('REFRESH_TOKEN_EXPIRATION_TIME');

private readonly COOKIE_SAME_SITE = this.configService.getOrThrow<string>('COOKIE_SAME_SITE');

constructor(
private readonly configService: ConfigService,
Expand All @@ -37,6 +37,7 @@ export class JwtUtilityService implements IJwtUtilityService.Base {
path: this.COOKIE_PATH,
httpOnly: this.IS_HTTP_ONLY_COOKIE,
secure: this.IS_SECURE_COOKIE,
sameSite: this.COOKIE_SAME_SITE,
};
}

Expand All @@ -47,6 +48,7 @@ export class JwtUtilityService implements IJwtUtilityService.Base {
httpOnly: this.IS_HTTP_ONLY_COOKIE,
secure: this.IS_SECURE_COOKIE,
maxAge: this.REFRESH_TOKEN_EXPIRATION_TIME,
sameSite: this.COOKIE_SAME_SITE,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ export namespace IJwtUtilityService {
httpOnly: boolean;
secure: boolean;
maxAge?: number;
sameSite?: string;
}
}
5 changes: 5 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ async function bootstrap() {

const servicePort = configService.getOrThrow<number>('SERVICE_PORT');

app.enableCors({
credentials: true,
origin: process.env.CORS_ALLOW_ORIGIN.split(','),
});

const config = new DocumentBuilder()
.setTitle('Muzi API')
.setDescription('무지 백엔드 서비스')
Expand Down

0 comments on commit 118fd5e

Please sign in to comment.