From 43898b3b951c43ce3a5f3f15412a794f0091607a Mon Sep 17 00:00:00 2001 From: Toast Date: Thu, 30 Jan 2025 10:23:04 +0100 Subject: [PATCH] Only enable CORS on production --- src/main.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index 9da9f87..6327a1f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,12 +1,20 @@ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; +import { Logger } from '@nestjs/common'; async function bootstrap() { const app = await NestFactory.create(AppModule); - app.enableCors({ - credentials: true, - origin: ['https://shows.everest.tailscale/admin/'] - }); + + if (process.env.NODE_ENV == 'production') { + app.enableCors({ + credentials: true, + origin: ['https://shows.everest.tailscale/admin/'], + }); + } else { + const logger = new Logger("bootstrap") + logger.log("In development mode, not enabling CORS") + } + await app.listen(process.env.PORT ?? 3000); } bootstrap();