From 719c75616e47df8ca0a8c3652f62b7cc24fe849f Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Wed, 13 Nov 2024 13:35:41 +0100 Subject: [PATCH] CORS fix --- src/server.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/server.ts b/src/server.ts index a1d3a9e..9d516aa 100644 --- a/src/server.ts +++ b/src/server.ts @@ -27,11 +27,12 @@ export class Server { */ constructor() { this.app = express() - this.app.use( - cors({ - origin: config.CLIENT_URL // Allow CORS from the client URL - }) - ) + this.app.use(cors({ + origin: config.CLIENT_URL, + methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], // Add supported methods + allowedHeaders: ['Content-Type', 'Authorization'], // Add allowed headers + credentials: true // Enable if you're using cookies/credentials + })) this.app.use(express.json()) this.app.use(express.urlencoded({ extended: true })) this.http = httpServer(this.app)