Skip to content

Commit db89242

Browse files
committed
fix domjudge fetch
1 parent 936baf3 commit db89242

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/server/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const serverSchema = Schema.intersect([
6868
Schema.const('domjudge'),
6969
Schema.const('hydro'),
7070
] as const).required(),
71-
server: Schema.string().role('url').required(),
71+
server: Schema.transform(String, (i) => (i.endsWith('/') ? i : `${i}/`)).role('url').required(),
7272
contestId: Schema.string(),
7373
token: Schema.string(),
7474
username: Schema.string(),

packages/server/service/fetcher.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ class DOMjudgeFetcher extends BasicFetcher {
6464
async contestInfo() {
6565
let contest;
6666
if (!config.contestId) {
67-
const { body } = await fetch('/api/v4/contests?onlyActive=true');
67+
const { body } = await fetch('./api/v4/contests?onlyActive=true');
6868
if (!body || !body.length) {
6969
logger.error('Contest not found');
7070
return false;
7171
}
7272
contest = body[0];
7373
} else {
74-
const { body } = await fetch(`/api/v4/contests/${config.contestId}`);
74+
const { body } = await fetch(`./api/v4/contests/${config.contestId}`);
7575
if (!body || !body.id) {
7676
logger.error(`Contest ${config.contestId} not found`);
7777
return false;
@@ -88,7 +88,7 @@ class DOMjudgeFetcher extends BasicFetcher {
8888
}
8989

9090
async teamInfo() {
91-
const { body } = await fetch(`/api/v4/contests/${this.contest.id}/teams`);
91+
const { body } = await fetch(`./api/v4/contests/${this.contest.id}/teams`);
9292
if (!body || !body.length) return;
9393
const teams = body;
9494
for (const team of teams) {
@@ -99,7 +99,7 @@ class DOMjudgeFetcher extends BasicFetcher {
9999

100100
async balloonInfo(all) {
101101
if (all) logger.info('Sync all balloons...');
102-
const { body } = await fetch(`/api/v4/contests/${this.contest.id}/balloons?todo=${all ? 'false' : 'true'}`);
102+
const { body } = await fetch(`./api/v4/contests/${this.contest.id}/balloons?todo=${all ? 'false' : 'true'}`);
103103
if (!body || !body.length) return;
104104
const balloons = body;
105105
for (const balloon of balloons) {
@@ -136,7 +136,7 @@ class DOMjudgeFetcher extends BasicFetcher {
136136
}
137137

138138
async setBalloonDone(bid) {
139-
await fetch(`/api/v4/contests/${this.contest.id}/balloons/${bid}/done`, 'post');
139+
await fetch(`./api/v4/contests/${this.contest.id}/balloons/${bid}/done`, 'post');
140140
logger.debug(`Balloon ${bid} set done`);
141141
}
142142
}

0 commit comments

Comments
 (0)