This commit is contained in:
parent
c53f2bfbc9
commit
4a1f943339
@ -118,18 +118,18 @@ export class AuthService {
|
||||
}
|
||||
|
||||
getCookieOptions(isRefreshToken = false) {
|
||||
// const isProduction =
|
||||
// this.configService.get<string>("NODE_ENV") === "production";
|
||||
// const cookieSecure =
|
||||
// this.configService.get<string>("COOKIE_SECURE") === "true";
|
||||
// const domain = this.configService.get<string>("COOKIE_DOMAIN");
|
||||
const isProduction =
|
||||
this.configService.get<string>("NODE_ENV") === "production";
|
||||
const cookieSecure =
|
||||
this.configService.get<string>("COOKIE_SECURE") === "true";
|
||||
const domain = this.configService.get<string>("COOKIE_DOMAIN");
|
||||
|
||||
return {
|
||||
httpOnly: true,
|
||||
// secure: isProduction || cookieSecure,
|
||||
secure: true,
|
||||
sameSite: "none" as const,
|
||||
path: isRefreshToken ? "/auth/refresh" : "/",
|
||||
// domain: domain,
|
||||
domain: domain,
|
||||
maxAge: isRefreshToken ? 7 * 24 * 60 * 60 * 1000 : 15 * 60 * 1000,
|
||||
};
|
||||
}
|
||||
|
||||
21
src/main.ts
21
src/main.ts
@ -12,8 +12,25 @@ async function bootstrap() {
|
||||
app.enableCors({
|
||||
origin: corsOrigins,
|
||||
credentials: true,
|
||||
methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"],
|
||||
allowedHeaders: ["Content-Type", "Authorization", "X-Requested-With"],
|
||||
allowedHeaders: [
|
||||
"Content-Type",
|
||||
"Authorization",
|
||||
"X-Requested-With",
|
||||
"Accept",
|
||||
"Origin",
|
||||
"Access-Control-Request-Method",
|
||||
"Access-Control-Request-Headers",
|
||||
"Cache-Control",
|
||||
],
|
||||
exposedHeaders: [
|
||||
"Authorization",
|
||||
"Set-Cookie",
|
||||
"Access-Control-Allow-Origin",
|
||||
"Access-Control-Allow-Credentials",
|
||||
],
|
||||
preflightContinue: false,
|
||||
optionsSuccessStatus: 204,
|
||||
maxAge: 86400, // 24 hours
|
||||
});
|
||||
|
||||
app.use(cookieParser());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user