Update backend/src/main.ts
All checks were successful
Anatid Blog CI Workflow / test (./backend) (push) Successful in 27s
Anatid Blog CI Workflow / test (./frontend) (push) Successful in 31s
Anatid Blog CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/anatid-blog-backend, ./backend) (push) Successful in 52s
Anatid Blog CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/anatid-blog-frontend, ./frontend) (push) Successful in 44s
Anatid Blog CI Workflow / deploy (push) Successful in 21s

Another go at cors
This commit is contained in:
Phill Pover 2025-03-28 15:38:57 +00:00
parent a58bb6b8dc
commit 84ad2b7684

View File

@ -1,19 +1,14 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
const corsOptions = {
origin: 'https://blog.anatid.net',
methods: 'GET,POST,PATCH,DELETE,OPTIONS',
optionsSuccessStatus: 200
};
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
app.enableCors({ app.enableCors({
origin: ['https://blog.anatid.net'], // Allowed origins origin: ['https://blog.anatid.net'],
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', // Allowed methods methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
credentials: true, // Allow credentials (e.g., cookies) credentials: true,
allowedHeaders: 'Content-Type, Accept', // Allowed headers allowedHeaders: 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept, Observe', // Allowed headers
}); });
await app.listen(process.env.PORT ?? 3000); await app.listen(process.env.PORT ?? 3000);
} }