move xs-securiry.json

This commit is contained in:
Dzmitry_Tamashevich@epam.com
2020-11-29 21:32:14 +03:00
committed by Daniel Hutzel
parent ee63541845
commit 64cc4ec26a
4 changed files with 25 additions and 21 deletions

View File

@@ -22,7 +22,29 @@ const getFormattedDateTime = () => {
return formattedDateTime;
};
const corsMiddleware = (req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Methods",
"GET, PUT, PATCH, POST, DELETE, OPTIONS"
);
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept, Authorization, Accept-Language"
);
//intercepts OPTIONS method
if ("OPTIONS" === req.method) {
//respond with 200
res.sendStatus(200);
} else {
//move on
next();
}
};
module.exports = {
getFormattedDateTime,
getDurationInMilliseconds,
corsMiddleware,
};