Relax CSRF check in non-prod when Origin/Referer missing
This commit is contained in:
@@ -103,6 +103,10 @@ app.use((req, res, next) => {
|
||||
// Some clients omit Origin; allow Referer as fallback.
|
||||
if ((origin && ok(origin)) || (!origin && referer && ok(referer))) return next();
|
||||
|
||||
// In non-production MVP/dev environments, be permissive if headers are missing.
|
||||
// (Notably some browsers/proxies can omit Origin/Referer on same-origin form posts.)
|
||||
if (!isProd && !origin && !referer) return next();
|
||||
|
||||
return res.status(403).send('Blocked (CSRF)');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user