From 70cfbd1043b7e1a9e0ad42a29ca0a2634a16848a Mon Sep 17 00:00:00 2001 From: Davide <43080019+edivados@users.noreply.github.com> Date: Sat, 12 Aug 2023 08:15:27 +0000 Subject: [PATCH 1/3] fix bug where cloudflare pages adapter looks for file ending in query params --- packages/start-cloudflare-pages/entry.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/start-cloudflare-pages/entry.js b/packages/start-cloudflare-pages/entry.js index b5729d451..7a16ab685 100644 --- a/packages/start-cloudflare-pages/entry.js +++ b/packages/start-cloudflare-pages/entry.js @@ -3,7 +3,7 @@ import handler from "./entry-server"; export const onRequestGet = async ({ request, next, env }) => { // Handle static assets - if (/\.\w+$/.test(request.url)) { + if (/\.\w+$/.test(request.url.pathname)) { let resp = await next(request); if (resp.status === 200 || 304) { return resp; @@ -44,7 +44,7 @@ export const onRequestGet = async ({ request, next, env }) => { export const onRequestHead = async ({ request, next, env }) => { // Handle static assets - if (/\.\w+$/.test(request.url)) { + if (/\.\w+$/.test(request.url.pathname)) { let resp = await next(request); if (resp.status === 200 || 304) { return resp; From f9d6529b4875045d932060ff8bbbfddb54ecb4bb Mon Sep 17 00:00:00 2001 From: Davide <43080019+edivados@users.noreply.github.com> Date: Sat, 12 Aug 2023 12:23:49 +0200 Subject: [PATCH 2/3] now fixed --- packages/start-cloudflare-pages/entry.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/start-cloudflare-pages/entry.js b/packages/start-cloudflare-pages/entry.js index 7a16ab685..a0337ee9a 100644 --- a/packages/start-cloudflare-pages/entry.js +++ b/packages/start-cloudflare-pages/entry.js @@ -3,7 +3,7 @@ import handler from "./entry-server"; export const onRequestGet = async ({ request, next, env }) => { // Handle static assets - if (/\.\w+$/.test(request.url.pathname)) { + if (/\.\w+$/.test(new URL(request.url).pathname)) { let resp = await next(request); if (resp.status === 200 || 304) { return resp; @@ -44,7 +44,7 @@ export const onRequestGet = async ({ request, next, env }) => { export const onRequestHead = async ({ request, next, env }) => { // Handle static assets - if (/\.\w+$/.test(request.url.pathname)) { + if (/\.\w+$/.test(new URL(request.url).pathname)) { let resp = await next(request); if (resp.status === 200 || 304) { return resp; From 5d079106031905f0e84d758e0858e0799ea55f7a Mon Sep 17 00:00:00 2001 From: Davide <43080019+edivados@users.noreply.github.com> Date: Sat, 12 Aug 2023 12:47:20 +0200 Subject: [PATCH 3/3] Update entry.js only return asset reponse on 200 and 304 --- packages/start-cloudflare-pages/entry.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/start-cloudflare-pages/entry.js b/packages/start-cloudflare-pages/entry.js index a0337ee9a..38ae51039 100644 --- a/packages/start-cloudflare-pages/entry.js +++ b/packages/start-cloudflare-pages/entry.js @@ -5,7 +5,7 @@ export const onRequestGet = async ({ request, next, env }) => { // Handle static assets if (/\.\w+$/.test(new URL(request.url).pathname)) { let resp = await next(request); - if (resp.status === 200 || 304) { + if (resp.status === 200 || resp.status === 304) { return resp; } } @@ -46,7 +46,7 @@ export const onRequestHead = async ({ request, next, env }) => { // Handle static assets if (/\.\w+$/.test(new URL(request.url).pathname)) { let resp = await next(request); - if (resp.status === 200 || 304) { + if (resp.status === 200 || resp.status === 304) { return resp; } }