Skip to content

Commit 44fd8fe

Browse files
committed
return 404 in cloudflare when not project found
1 parent 6670ead commit 44fd8fe

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

web/cloudflare/functions/projects/[slug].ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ export const onRequest: PagesFunction<Env> = async (context) => {
4141

4242
// @TODO-ZM: use fetchV2
4343
const projectResponse = await fetch(`${apiUrl}/Projects/${projectId}/name`);
44+
45+
if (!projectResponse.ok) {
46+
return new Response(notFoundEn, {
47+
headers: { "content-type": "text/html; charset=utf-8" },
48+
status: 404,
49+
});
50+
}
51+
4452
const projectData = await projectResponse.json();
4553
// @ts-expect-error @TODO-ZM: import @dzcode.io/api
4654
const pageTitle = `${localize("project-title-pre")} ${projectData.project.name} ${localize("project-title-post")}`;

0 commit comments

Comments
 (0)