This repository has been archived on 2026-05-01. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
PolyNotFound/config/cors.config.js
2021-12-29 18:51:56 +01:00

28 lines
No EOL
752 B
JavaScript

const cors = require('cors');
module.exports.cors = cors;
const allowList = [
'http://127.0.0.1:4200',
'http://127.0.0.1:4201',
'https://admin-polynotfound.herokuapp.com',
'https://polynotfound.herokuapp.com'
];
const corsOptionsDelegate = function(req, callback) {
console.log(req.header('Origin'), allowList.indexOf(req.header('Origin')));
let corsOptions;
if (allowList.indexOf(req.header('Origin')) !== -1) {
corsOptions = {
origin: true,
credentials: true
}
} else {
corsOptions = {
origin: false,
credentials: true
}
}
console.log(corsOptions);
callback(null, corsOptions)
}
module.exports.options = corsOptionsDelegate;