You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

21 lines
461 B

const corsOptions = {
origin: (origin, callback) => {
const whitelist = [
'http://localhost:3000',
'http://localhost:8080',
'http://localhost',
'http://umbrel.local',
...process.env.DEVICE_HOSTS.split(",")
];
if (whitelist.indexOf(origin) !== -1 || !origin) {
return callback(null, true);
} else {
return callback(new Error('Not allowed by CORS'));
}
}
};
module.exports = {
corsOptions,
};