Files
freeCodeCamp/api-server/server/middlewares/csurf.js

24 lines
522 B
JavaScript
Raw Normal View History

2016-05-02 17:22:56 -07:00
import csurf from 'csurf';
export default function() {
const protection = csurf({
cookie: {
domain: process.env.COOKIE_DOMAIN || 'localhost',
sameSite: 'strict',
secure: true
}
});
2016-05-02 21:11:49 -07:00
return function csrf(req, res, next) {
const { path } = req;
if (
// eslint-disable-next-line max-len
/^\/hooks\/update-paypal$|^\/hooks\/update-stripe$|^\/donate\/charge-stripe$/.test(
path
)
) {
2016-05-02 21:11:49 -07:00
return next();
}
return protection(req, res, next);
};
2016-05-02 17:22:56 -07:00
}