From d45fbee6478659432cbf57fd74d8f485170683f5 Mon Sep 17 00:00:00 2001 From: chreamy Date: Thu, 18 Jan 2024 03:23:39 -0600 Subject: [PATCH] fix: CSRF issue #51 --- server/src/api/routes/index.js | 1 + server/src/middleware/csrfProtection.js | 1 + 2 files changed, 2 insertions(+) diff --git a/server/src/api/routes/index.js b/server/src/api/routes/index.js index 2f66036..5a52f4b 100644 --- a/server/src/api/routes/index.js +++ b/server/src/api/routes/index.js @@ -9,6 +9,7 @@ import userRouter from './userRouter.js' import config from '../../config.js' import leaderboardController from '../controllers/leaderboardController.js' import csrfProtection from '../../middleware/csrfProtection.js' + const router = Router() if (!config.isProduction) { diff --git a/server/src/middleware/csrfProtection.js b/server/src/middleware/csrfProtection.js index 566dde6..94b77c6 100644 --- a/server/src/middleware/csrfProtection.js +++ b/server/src/middleware/csrfProtection.js @@ -1,4 +1,5 @@ import csrf from 'csurf' + const CSRF = csrf({ cookie: true }) function csrfProtection(req, res, next) { if (req.method === 'POST') {