Created
January 30, 2022 14:57
-
-
Save tadeaspetak/ec3a739548fd242b1d3145e0a43d428f to your computer and use it in GitHub Desktop.
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 api = express.Router(); | |
// enforce `application/json` content type on all api endpoints | |
api.use((req, res, next) => { | |
if (req.headers["content-type"] !== "application/json") { | |
res.status(400).json({ message: "Invalid content type." }); | |
} else { | |
next(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment