mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-04 09:05:49 -05:00
13 lines
285 B
JavaScript
13 lines
285 B
JavaScript
import csurf from 'csurf';
|
|
|
|
export default function() {
|
|
const protection = csurf({ cookie: true });
|
|
return function csrf(req, res, next) {
|
|
const path = req.path.split('/')[1];
|
|
if (/api/.test(path)) {
|
|
return next();
|
|
}
|
|
return protection(req, res, next);
|
|
};
|
|
}
|