Created
April 26, 2021 23:56
-
-
Save gmoqa/08d53e4346de29075de9c5e6bba1562b to your computer and use it in GitHub Desktop.
Disable HTTP Methods in Nuxt.js
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
const allowedMethods = ['GET', 'HEAD'] | |
export default function (req, res, next) { | |
if (!allowedMethods.includes(req.method)) { | |
res.writeHead(405) | |
res.end('Method Not Allowed') | |
return | |
} | |
next() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment