add CORS to server, input appUrl

This commit is contained in:
Amruth Pillai
2022-12-16 15:04:08 +00:00
parent dbc46f27a3
commit 2ba6658a0b
4 changed files with 10 additions and 9 deletions

View File

@ -10,8 +10,10 @@ const bootstrap = async () => {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
const configService = app.get(ConfigService);
const appUrl = configService.get<string>('app.url');
// Middleware
app.enableCors({ credentials: true });
app.enableCors({ origin: [appUrl], credentials: true });
app.enableShutdownHooks();
app.use(cookieParser());