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.
26 lines
573 B
26 lines
573 B
5 years ago
|
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.UMBREL_HIDDEN_SERVICE) {
|
||
|
whitelist.push(process.env.UMBREL_HIDDEN_SERVICE);
|
||
|
}
|
||
|
|
||
|
if (whitelist.indexOf(origin) !== -1 || !origin) {
|
||
|
return callback(null, true);
|
||
|
} else {
|
||
|
return callback(new Error('Not allowed by CORS'));
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
module.exports = {
|
||
|
corsOptions,
|
||
|
};
|