Files
freeCodeCamp/api-server/server/middlewares/csurf.js
2020-03-19 17:18:53 +05:30

17 lines
380 B
JavaScript

import csurf from 'csurf';
export default function() {
const protection = csurf({
cookie: {
domain: process.env.COOKIE_DOMAIN || 'localhost'
}
});
return function csrf(req, res, next) {
const { path } = req;
if (/^\/hooks\/update-paypal$|^\/hooks\/update-stripe$/.test(path)) {
return next();
}
return protection(req, res, next);
};
}