Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
node: setAllowHeader()
import { NextFunction, Request, Response } from 'express';
/**
* Sets Allow header.
*
* "The Allow header lists the set of methods support by a resource.
* This header must be sent if the server responds with a 405 Method Not Allowed
* status code to indicate which request methods can be used."
*
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Allow
*/
export const setAllowHeader = (req: Request, res: Response, next: NextFunction) => {
res.set('allow', 'GET, POST, OPTIONS');
next();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment