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.
This commit is contained in:
Torsten Schulz (local)
2026-03-27 09:49:54 +01:00
parent 1878b2a8c7
commit 21072139f7

View File

@@ -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);