From a58bb6b8dc6ec31d6a1ebd6986030152d4528914 Mon Sep 17 00:00:00 2001 From: Phill Pover Date: Fri, 28 Mar 2025 13:27:28 +0000 Subject: [PATCH 1/2] Update backend/src/main.ts Fixing cors --- backend/src/main.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/src/main.ts b/backend/src/main.ts index e03661f..8e98628 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -8,7 +8,13 @@ const corsOptions = { async function bootstrap() { const app = await NestFactory.create(AppModule); - app.enableCors(corsOptions); + app.enableCors({ + origin: ['https://blog.anatid.net'], // Allowed origins + methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', // Allowed methods + credentials: true, // Allow credentials (e.g., cookies) + allowedHeaders: 'Content-Type, Accept', // Allowed headers + }); + await app.listen(process.env.PORT ?? 3000); } From 84ad2b7684f9a710214f8a0a5af30840795281e0 Mon Sep 17 00:00:00 2001 From: Phill Pover Date: Fri, 28 Mar 2025 15:38:57 +0000 Subject: [PATCH 2/2] Update backend/src/main.ts Another go at cors --- backend/src/main.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/backend/src/main.ts b/backend/src/main.ts index 8e98628..5cd16d1 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -1,19 +1,14 @@ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; -const corsOptions = { - origin: 'https://blog.anatid.net', - methods: 'GET,POST,PATCH,DELETE,OPTIONS', - optionsSuccessStatus: 200 -}; async function bootstrap() { const app = await NestFactory.create(AppModule); app.enableCors({ - origin: ['https://blog.anatid.net'], // Allowed origins - methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', // Allowed methods - credentials: true, // Allow credentials (e.g., cookies) - allowedHeaders: 'Content-Type, Accept', // Allowed headers - }); + origin: ['https://blog.anatid.net'], + methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', + credentials: true, + allowedHeaders: 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept, Observe', // Allowed headers + }); await app.listen(process.env.PORT ?? 3000); }