Only enable CORS on production
This commit is contained in:
parent
c25a6be9f4
commit
43898b3b95
1 changed files with 12 additions and 4 deletions
10
src/main.ts
10
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);
|
||||
|
||||
if (process.env.NODE_ENV == 'production') {
|
||||
app.enableCors({
|
||||
credentials: true,
|
||||
origin: ['https://shows.everest.tailscale/admin/']
|
||||
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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue