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.
 
 
 

25 lines
579 B

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