chore(backend): configure CORS for development and production environments (#4430)
Co-authored-by: mirarifhasan <arif.ishan05@gmail.com>
This commit is contained in:
parent
46e5792965
commit
9b0e1af92d
1 changed files with 6 additions and 7 deletions
|
|
@ -41,7 +41,7 @@ async function bootstrap() {
|
|||
|
||||
const configService = app.get(ConfigService);
|
||||
|
||||
console.log(`Running in production: ${configService.get('PRODUCTION')}`);
|
||||
console.log(`Running in production: ${configService.get('PRODUCTION')}`);
|
||||
console.log(`Port: ${configService.get('PORT')}`);
|
||||
|
||||
checkEnvironmentAuthProvider(
|
||||
|
|
@ -62,21 +62,20 @@ async function bootstrap() {
|
|||
}),
|
||||
);
|
||||
|
||||
if (configService.get('PRODUCTION') === 'false') {
|
||||
console.log('Enabling CORS with development settings');
|
||||
|
||||
if (configService.get('PRODUCTION') === 'true') {
|
||||
console.log('Enabling CORS with production settings');
|
||||
app.enableCors({
|
||||
origin: configService.get('WHITELISTED_ORIGINS').split(','),
|
||||
credentials: true,
|
||||
});
|
||||
} else {
|
||||
console.log('Enabling CORS with production settings');
|
||||
|
||||
console.log('Enabling CORS with development settings');
|
||||
app.enableCors({
|
||||
origin: configService.get('WHITELISTED_ORIGINS').split(','),
|
||||
origin: true,
|
||||
credentials: true,
|
||||
});
|
||||
}
|
||||
|
||||
app.enableVersioning({
|
||||
type: VersioningType.URI,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue