mirror of
https://github.com/hexastack/hexabot
synced 2025-02-23 12:59:14 +00:00
fix: load setting
This commit is contained in:
parent
97cff8acff
commit
1452638a64
@ -49,14 +49,18 @@ async function bootstrap() {
|
|||||||
app.use(bodyParser.json({ verify: rawBodyBuffer }));
|
app.use(bodyParser.json({ verify: rawBodyBuffer }));
|
||||||
|
|
||||||
const settingService = app.get<SettingService>(SettingService);
|
const settingService = app.get<SettingService>(SettingService);
|
||||||
const allowedOrigins = await settingService.getAllowedOrigins();
|
|
||||||
app.enableCors({
|
app.enableCors({
|
||||||
origin: (origin, callback) => {
|
origin: (origin, callback) => {
|
||||||
|
settingService
|
||||||
|
.getAllowedOrigins()
|
||||||
|
.then((allowedOrigins) => {
|
||||||
if (!origin || allowedOrigins.has(origin)) {
|
if (!origin || allowedOrigins.has(origin)) {
|
||||||
callback(null, true);
|
callback(null, true);
|
||||||
} else {
|
} else {
|
||||||
callback(new Error('Not allowed by CORS'));
|
callback(new Error('Not allowed by CORS'));
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(callback);
|
||||||
},
|
},
|
||||||
methods: config.security.cors.methods,
|
methods: config.security.cors.methods,
|
||||||
credentials: config.security.cors.allowCredentials,
|
credentials: config.security.cors.allowCredentials,
|
||||||
|
Loading…
Reference in New Issue
Block a user