CSRF token removed only for login api : GWM
This commit is contained in:
parent
ae236502cd
commit
de5c505e01
11
server.js
11
server.js
@ -16,13 +16,16 @@ require("dotenv").config();
|
|||||||
|
|
||||||
const csrf = require("csurf");
|
const csrf = require("csurf");
|
||||||
|
|
||||||
// cookie-based CSRF protection
|
const isProd = process.env.NODE_ENV === "production";
|
||||||
|
|
||||||
const csrfProtection = csrf({
|
const csrfProtection = csrf({
|
||||||
cookie: {
|
cookie: {
|
||||||
key: "_csrf",
|
key: "_csrf",
|
||||||
httpOnly: true,
|
httpOnly: true, // always true
|
||||||
secure: process.env.NODE_ENV === "production",
|
secure: isProd, // true only in production (HTTPS)
|
||||||
sameSite: "strict",
|
sameSite: isProd ? "none" : "lax",
|
||||||
|
// prod: cross-domain frontend → backend
|
||||||
|
// dev : localhost friendly
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user