Skip to content
This repository was archived by the owner on Jun 2, 2024. It is now read-only.

Commit da22995

Browse files
committed
cors config
1 parent 6335e3d commit da22995

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Kirin/classes/APIClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class APIClient<Ready extends boolean = boolean> {
3737

3838
this._express.use(bodyParser.urlencoded({ extended: false }));
3939
this._express.use(bodyParser.json());
40-
this._express.use(cors({ origin: "*" }));
40+
this._express.use(cors(this.kirin.config.api.cors));
4141

4242
await this.loadRoutes();
4343

src/Kirin/utils/config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CorsOptions, CorsOptionsDelegate } from 'cors';
12
import { BaseMessageOptions, PermissionResolvable, inlineCode } from 'discord.js';
23
import { createReadFile } from 'fallout-utility';
34
import { writeFileSync } from 'fs';
@@ -11,6 +12,7 @@ export interface Config {
1112
enabled: boolean;
1213
port: number;
1314
password: string|null;
15+
cors: CorsOptions|CorsOptionsDelegate;
1416
};
1517
command: {
1618
enabled: boolean;
@@ -38,7 +40,8 @@ export const defaultConfig: Config = {
3840
api: {
3941
enabled: false,
4042
port: 55667,
41-
password: null
43+
password: null,
44+
cors: { origin: '*' }
4245
},
4346
command: {
4447
enabled: true,

0 commit comments

Comments
 (0)