Skip to content

Commit

Permalink
Add config support for frontend origin
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteHoodHacker authored Jun 18, 2024
1 parent ab5b166 commit 508cc18
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ app.register(helmet, {
}
})

app.register(cors, {
origin: "https://uiuctf-2024-rctf-frontend.pages.dev"
})
if (config.originFrontend) {
app.register(cors, {
origin: config.originFrontend
})
}

uploadProviderInit(app)

Expand Down
1 change: 1 addition & 0 deletions server/config/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type ServerConfig = {
instanceType: string;
tokenKey: string;
origin: string;
originFrontend?: string;

// TODO: enforce `trust` is false when `cloudflare` is true
proxy: {
Expand Down
2 changes: 1 addition & 1 deletion server/email/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (emailConfig) {
const emailView = {
ctf_name: config.ctfName,
logo_url: config.logoUrl,
origin: config.origin,
origin: config.originFrontend ?? config.origin,
token: encodeURIComponent(token),
register: kind === 'register',
recover: kind === 'recover',
Expand Down

0 comments on commit 508cc18

Please sign in to comment.