From cc1997b099e5a35f446ddcd5fa16db069b35e0cd Mon Sep 17 00:00:00 2001 From: soufiane Date: Sun, 7 Dec 2025 17:42:12 +0100 Subject: [PATCH] fix: remove explicit OPTIONS handler causing path-to-regexp error --- index.js | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/index.js b/index.js index 09eb58cf..0ad1fabe 100644 --- a/index.js +++ b/index.js @@ -20,32 +20,6 @@ import contactRoutes from "./src/routes/contact.routes.js"; const app = express(); -// Handler explicite pour les requêtes preflight OPTIONS -app.options('*', (req, res) => { - const allowedOrigins = [ - "http://localhost:3000", - "http://localhost:3001", - "http://localhost:3002", - "http://localhost:3003", - "http://localhost:3004", - "http://localhost:3005", - "https://dsp5-archi-o24a-15m-g3.fr", - "https://dev.dsp5-archi-o24a-15m-g3.fr", - "https://preprod.dsp5-archi-o24a-15m-g3.fr" - ]; - const origin = req.headers.origin; - if (!origin || allowedOrigins.includes(origin)) { - res.header('Access-Control-Allow-Origin', origin || '*'); - } else { - res.header('Access-Control-Allow-Origin', origin); // Autorise tout en dev - } - res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS'); - res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With'); - res.header('Access-Control-Allow-Credentials', 'true'); - res.header('Access-Control-Max-Age', '86400'); - res.sendStatus(204); -}); - // CORS doit être configuré AVANT helmet app.use( cors({