Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
fix(Api): render404 not working
Browse files Browse the repository at this point in the history
  • Loading branch information
ijsKoud committed Sep 12, 2023
1 parent 95aeab0 commit a7a917d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions apps/server/src/lib/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ export class Api {
const files = this.readdirRecursive(join(__dirname, "..", "api")).filter((file) => file.endsWith(".js"));
await Promise.all(files.map((filePath) => this.loadFile(filePath)));

this.server.express.get("/files/:file", rateLimit({ max: 2e2, windowMs: 1e3 }), async (req, res) => {
this.server.express.get("/files/:file", rateLimit({ max: 2e2, windowMs: 1e3 }), async (req, res, next) => {
const { file: fileName } = req.params;

const domain = this.server.domains.get(req.headers.host || req.hostname);
if (!domain) {
await this.server.next.render404(req, res);
await this.server.next.render(req, res, "/404");
return;
}

if (domain.disabled) {
await this.server.next.render404(req, res);
await this.server.next.render(req, res, "/404");
return;
}

Expand All @@ -44,7 +44,7 @@ export class Api {
};

if (!file || (!file.visible && !checkForAuth())) {
await this.server.next.render404(req, res);
await this.server.next.render(req, res, "/404");
return;
}

Expand Down Expand Up @@ -100,12 +100,12 @@ export class Api {

const domain = this.server.domains.get(req.headers.host || req.hostname);
if (!domain) {
await this.server.next.render404(req, res);
await this.server.next.render(req, res, "/404");
return;
}

if (domain.disabled) {
await this.server.next.render404(req, res);
await this.server.next.render(req, res, "/404");
return;
}

Expand All @@ -122,7 +122,7 @@ export class Api {
};

if (!url || (!url.visible && !checkForAuth())) {
await this.server.next.render404(req, res);
await this.server.next.render(req, res, "/404");
return;
}

Expand Down

0 comments on commit a7a917d

Please sign in to comment.