From 9b0e1af92dcc66e8f8d6c5241017f77b650aed39 Mon Sep 17 00:00:00 2001 From: Binayak Bhattacharjee Date: Wed, 14 May 2025 12:29:24 +0530 Subject: [PATCH] chore(backend): configure CORS for development and production environments (#4430) Co-authored-by: mirarifhasan --- packages/hoppscotch-backend/src/main.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/hoppscotch-backend/src/main.ts b/packages/hoppscotch-backend/src/main.ts index 313bbfff..fb39809a 100644 --- a/packages/hoppscotch-backend/src/main.ts +++ b/packages/hoppscotch-backend/src/main.ts @@ -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, });