Files
freeCodeCamp/api-server/src/server/middlewares/csurf.js
Ahmad Abdolsaheb 27c8d564e4 fix(client): replace Stripe with PayPal (#41924)
* feat: remove stripe payment option from client

* feat: remove stripe completely

* fix: remove last Stripe remnants

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2021-05-03 11:45:23 +03:00

22 lines
510 B
JavaScript

import csurf from 'csurf';
export default function getCsurf() {
const protection = csurf({
cookie: {
domain: process.env.COOKIE_DOMAIN || 'localhost',
sameSite: 'strict',
secure: process.env.FREECODECAMP_NODE_ENV === 'production'
}
});
return function csrf(req, res, next) {
const { path } = req;
if (
// eslint-disable-next-line max-len
/^\/hooks\/update-paypal$/.test(path)
) {
return next();
}
return protection(req, res, next);
};
}