@bee.js/node
Version:
A JavaScript framework for making Node.js API´s
17 lines (14 loc) • 561 B
JavaScript
module.exports = function ({ next, router, configs = {} }) {
router.use((req, res) => {
if (!configs.headers) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET,POST,PUT,PATCH,DELETE,OPTIONS");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
}
if (req.method === "OPTIONS") return res.sendStatus(200);
for (const key in configs.headers || {}) {
res.header(key, configs.headers[key]);
}
});
next();
};