chore(backend): remove global api prefix
This commit is contained in:
21
src/main.ts
21
src/main.ts
@@ -25,7 +25,8 @@ async function bootstrap() {
|
|||||||
saveUninitialized: false,
|
saveUninitialized: false,
|
||||||
cookie: {
|
cookie: {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
sameSite: (process.env.SESSION_SAME_SITE as 'strict' | 'lax' | 'none') ?? 'lax',
|
sameSite:
|
||||||
|
(process.env.SESSION_SAME_SITE as 'strict' | 'lax' | 'none') ?? 'lax',
|
||||||
secure: sessionCookieSecure,
|
secure: sessionCookieSecure,
|
||||||
maxAge: Number(process.env.SESSION_MAX_AGE ?? 1000 * 60 * 60 * 24 * 7),
|
maxAge: Number(process.env.SESSION_MAX_AGE ?? 1000 * 60 * 60 * 24 * 7),
|
||||||
},
|
},
|
||||||
@@ -34,7 +35,7 @@ async function bootstrap() {
|
|||||||
|
|
||||||
// Récupérer les origines CORS depuis la variable d'environnement (séparées par des virgules)
|
// Récupérer les origines CORS depuis la variable d'environnement (séparées par des virgules)
|
||||||
const allowedOrigins = process.env.CORS_ORIGIN
|
const allowedOrigins = process.env.CORS_ORIGIN
|
||||||
? process.env.CORS_ORIGIN.split(',').map(origin => origin.trim())
|
? process.env.CORS_ORIGIN.split(',').map((origin) => origin.trim())
|
||||||
: ['http://localhost:3001'];
|
: ['http://localhost:3001'];
|
||||||
|
|
||||||
app.enableCors({
|
app.enableCors({
|
||||||
@@ -49,14 +50,14 @@ async function bootstrap() {
|
|||||||
credentials: true,
|
credentials: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
app.useGlobalPipes(new ValidationPipe({
|
app.useGlobalPipes(
|
||||||
whitelist: process.env.VALIDATION_WHITELIST === 'true',
|
new ValidationPipe({
|
||||||
forbidNonWhitelisted: process.env.VALIDATION_FORBID_NON_WHITELISTED === 'true',
|
whitelist: process.env.VALIDATION_WHITELIST === 'true',
|
||||||
transform: process.env.VALIDATION_TRANSFORM === 'true',
|
forbidNonWhitelisted:
|
||||||
}));
|
process.env.VALIDATION_FORBID_NON_WHITELISTED === 'true',
|
||||||
|
transform: process.env.VALIDATION_TRANSFORM === 'true',
|
||||||
const apiPrefix = process.env.API_PREFIX || 'api';
|
}),
|
||||||
app.setGlobalPrefix(apiPrefix);
|
);
|
||||||
|
|
||||||
const port = Number(process.env.PORT) || 3000;
|
const port = Number(process.env.PORT) || 3000;
|
||||||
await app.listen(port);
|
await app.listen(port);
|
||||||
|
|||||||
Reference in New Issue
Block a user