CSRF token removed only for login api : GWM

This commit is contained in:
Gowtham M 2025-12-18 19:54:36 +05:30
parent ae236502cd
commit de5c505e01

View File

@ -16,13 +16,16 @@ require("dotenv").config();
const csrf = require("csurf");
// cookie-based CSRF protection
const isProd = process.env.NODE_ENV === "production";
const csrfProtection = csrf({
cookie: {
key: "_csrf",
httpOnly: true,
secure: process.env.NODE_ENV === "production",
sameSite: "strict",
httpOnly: true, // always true
secure: isProd, // true only in production (HTTPS)
sameSite: isProd ? "none" : "lax",
// prod: cross-domain frontend → backend
// dev : localhost friendly
},
});