slate/common/middleware.js

18 lines
390 B
JavaScript
Raw Normal View History

2020-02-19 09:30:47 +03:00
export const CORS = async (req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header(
'Access-Control-Allow-Methods',
'GET, POST, PATCH, PUT, DELETE, OPTIONS'
);
res.header(
'Access-Control-Allow-Headers',
'Origin, Accept, Content-Type, Authorization'
);
if (req.method === 'OPTIONS') {
return res.status(200).end();
}
next();
};