fix: Server Error when requesting invalid locale

This commit is contained in:
Tom Moor 2020-12-20 11:53:09 -08:00
parent decbe4f643
commit 47ce8afcc5
1 changed files with 2 additions and 2 deletions

View File

@ -8,7 +8,6 @@ import sendfile from "koa-sendfile";
import serve from "koa-static";
import { languages } from "../shared/i18n";
import environment from "./env";
import { NotFoundError } from "./errors";
import apexRedirect from "./middlewares/apexRedirect";
import { opensearchResponse } from "./utils/opensearch";
import { robotsResponse } from "./utils/robots";
@ -78,7 +77,8 @@ router.get("/locales/:lng.json", async (ctx) => {
let { lng } = ctx.params;
if (!languages.includes(lng)) {
throw new NotFoundError();
ctx.status = 404;
return;
}
if (process.env.NODE_ENV === "production") {