Created
August 29, 2019 01:10
-
-
Save techieshark/621528c64c73851a6e28d6bb4b805cc3 to your computer and use it in GitHub Desktop.
node: setAllowHeader()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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