UNPKG

@mark01/express-utils

Version:

npm package that contains utilities for express.js

10 lines (9 loc) 340 B
import { AppError } from '../error'; export const xRequestedWith = () => (req, _, next) => { if (!req.headers['x-requested-with']) { next(new AppError('This API does not accept cross-site requests with browser agents unless from an authorized source.', 403)); return; } next(); }; export default xRequestedWith;