Rework CORS
This commit is contained in:
parent
0d7ce28743
commit
adf315a187
1 changed files with 9 additions and 6 deletions
15
src/main.ts
15
src/main.ts
|
|
@ -5,15 +5,18 @@ import { Logger } from '@nestjs/common';
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create(AppModule);
|
||||||
|
|
||||||
|
const logger = new Logger('bootstrap');
|
||||||
|
let origin = ['https://shows.everest.tailscale/admin/'];
|
||||||
if (process.env.NODE_ENV == 'production') {
|
if (process.env.NODE_ENV == 'production') {
|
||||||
app.enableCors({
|
logger.log('In production mode');
|
||||||
credentials: true,
|
|
||||||
origin: ['https://shows.everest.tailscale/admin/'],
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
const logger = new Logger("bootstrap")
|
logger.log('In development mode');
|
||||||
logger.log("In development mode, not enabling CORS")
|
origin.push("http://localhost:4200")
|
||||||
}
|
}
|
||||||
|
app.enableCors({
|
||||||
|
credentials: true,
|
||||||
|
origin,
|
||||||
|
});
|
||||||
|
|
||||||
await app.listen(process.env.PORT);
|
await app.listen(process.env.PORT);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue