The firefox tells me that I need to put the value “None” in the somesite attribute, but when I set it, the browser still thinks that Lax is used there, instead of None
enter image description here
(in text:
Some cookies are misusing the recommended “Samesite” attribute 2
Cookie “authToken” does not have a proper “samesite” attribute value.
Soon, cookies without the “SameSite” attribute or with an invalid
value will be treated as “Lax”. This means that the cookie will no
longer be sent in third-party contexts. If your application depends on
this cookie being available in such contexts, please add the
“SameSite=None” attribute to it. To know more about the “samesite”
attribute, read https://develope
r.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/Samesite
js.cookie.mjs:75:50 Cookie “user” does not have a proper “SameSite”
attribute value. Soon, cookies without the “SameSite” attribute or
with an invalid value will be treated as “Lax”. This means that the
cookie will no longer be sent in third-party contexts. If your
application depends on this cookie being available in such contexts,
please add the “Samesite=None” attribute to it. To know more about the
“samesite” attribute, read https://develope
r.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/Samesite
js.cookie.mjs:75:58
)
Code:
app.use(
cors({
origin: "https://59e5-185-9-186-241.ngrok-free.app",
methods: ["GET", "POST"],
allowedHeaders: ["Content-Type", "Authorization"],
credentials: true,
}),
);
app.post("/api/auth/telegram", (req, res) => {
const userData = req.body;
// Проверяем подпись
if (!validateTelegramAuth(userData)) {
console.log("Неверная подпись Telegram");
return res.status(403).json({ message: "Неверная подпись Telegram" });
}
// Генерируем JWT токен
const token = generateAuthToken(userData);
res.cookie('authToken', token, {
httpOnly: true,
secure: true,
sameSite: 'None',
partitioned: true,
maxAge: 7 * 24 * 60 * 60 * 1000,
});
res.cookie('user', userData, {
httpOnly: true,
secure: true,
sameSite: 'None',
partitioned: true,
maxAge: 7 * 24 * 60 * 60 * 1000,
});
console.log("Токен сгенерирован и отправлен:", token);
return res.json({ token });
});
I rebooted the server, accessed chatGPT, looked for solutions and similar cases on the Internet
Faynot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
4