mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat(api): add logging for CSRF addition (#59062)
This commit is contained in:
@@ -27,9 +27,11 @@ const csrf: FastifyPluginCallback = (fastify, _options, done) => {
|
||||
|
||||
// All routes except signout should add a CSRF token to the response
|
||||
fastify.addHook('onRequest', (_req, reply, done) => {
|
||||
const logger = fastify.log.child({ _req });
|
||||
const isSignout = _req.url === '/signout' || _req.url === '/signout/';
|
||||
|
||||
if (!isSignout) {
|
||||
logger.debug('Adding CSRF token to response');
|
||||
const token = reply.generateCsrf();
|
||||
void reply.setCookie(CSRF_COOKIE, token, {
|
||||
sameSite: 'strict',
|
||||
|
||||
Reference in New Issue
Block a user