fix: Server Error when requesting invalid locale
This commit is contained in:
@ -8,7 +8,6 @@ import sendfile from "koa-sendfile";
|
|||||||
import serve from "koa-static";
|
import serve from "koa-static";
|
||||||
import { languages } from "../shared/i18n";
|
import { languages } from "../shared/i18n";
|
||||||
import environment from "./env";
|
import environment from "./env";
|
||||||
import { NotFoundError } from "./errors";
|
|
||||||
import apexRedirect from "./middlewares/apexRedirect";
|
import apexRedirect from "./middlewares/apexRedirect";
|
||||||
import { opensearchResponse } from "./utils/opensearch";
|
import { opensearchResponse } from "./utils/opensearch";
|
||||||
import { robotsResponse } from "./utils/robots";
|
import { robotsResponse } from "./utils/robots";
|
||||||
@ -78,7 +77,8 @@ router.get("/locales/:lng.json", async (ctx) => {
|
|||||||
let { lng } = ctx.params;
|
let { lng } = ctx.params;
|
||||||
|
|
||||||
if (!languages.includes(lng)) {
|
if (!languages.includes(lng)) {
|
||||||
throw new NotFoundError();
|
ctx.status = 404;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.NODE_ENV === "production") {
|
if (process.env.NODE_ENV === "production") {
|
||||||
|
Reference in New Issue
Block a user