From 0d667d0e572d76d4c819816ddf51ed14b43e2551 Mon Sep 17 00:00:00 2001 From: Richard Cooke Date: Fri, 24 Jun 2022 20:30:47 +0100 Subject: [PATCH] fix: `@astrojs/clooudflare` 404 handling (#3695) --- .changeset/five-zoos-look.md | 5 +++++ packages/integrations/cloudflare/src/server.ts | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/five-zoos-look.md diff --git a/.changeset/five-zoos-look.md b/.changeset/five-zoos-look.md new file mode 100644 index 0000000000..f882dee9bc --- /dev/null +++ b/.changeset/five-zoos-look.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +fix custom 404 pages not rendering diff --git a/packages/integrations/cloudflare/src/server.ts b/packages/integrations/cloudflare/src/server.ts index 6a76c06ff4..032146691e 100644 --- a/packages/integrations/cloudflare/src/server.ts +++ b/packages/integrations/cloudflare/src/server.ts @@ -24,6 +24,11 @@ export function createExports(manifest: SSRManifest) { } // 404 + const _404Request = new Request(`${origin}/404`, request); + if (app.match(_404Request)) { + return app.render(_404Request); + } + return new Response(null, { status: 404, statusText: 'Not found',