From 21072139f77b37015b3f16d55f5d82be588b82d5 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 27 Mar 2026 09:49:54 +0100 Subject: [PATCH] fix(cors): refine CORS handling for OPTIONS requests - Updated CORS middleware to explicitly handle OPTIONS requests, ensuring proper preflight response and improving API request handling. --- backend/app.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/app.js b/backend/app.js index ee5d441..5699ad4 100644 --- a/backend/app.js +++ b/backend/app.js @@ -83,7 +83,12 @@ const corsOptions = { }; app.use(cors(corsOptions)); -app.options('*', cors(corsOptions)); +app.use((req, res, next) => { + if (req.method === 'OPTIONS') { + return cors(corsOptions)(req, res, next); + } + return next(); +}); app.use(express.json()); // To handle JSON request bodies app.use('/api/chat', chatRouter);