From dff9e8be5c5479643bc07628e18210a9deb6e6d1 Mon Sep 17 00:00:00 2001 From: Chalo Salvador Date: Wed, 15 Jan 2025 14:35:32 +0100 Subject: [PATCH 1/2] Handle 404 status code in the proxyResponse. --- src/frameworks/utils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/frameworks/utils.ts b/src/frameworks/utils.ts index 2bb8a9a0bd5..19e3414cbb9 100644 --- a/src/frameworks/utils.ts +++ b/src/frameworks/utils.ts @@ -208,7 +208,12 @@ export function simpleProxy(hostOrRequestHandler: string | RequestHandler) { originalRes.end(); }); } else { - const proxiedRes = proxyResponse(originalReq, originalRes, next); + const proxiedRes = proxyResponse(originalReq, originalRes, () => { + // This next function is called when the proxied response is a 404 + // In that case we want to let the handler to use the original response + void hostOrRequestHandler(originalReq, originalRes, next); + }); + await hostOrRequestHandler(originalReq, proxiedRes, next); } }; From 774423fece52819820905d029f8f382b773ee6c0 Mon Sep 17 00:00:00 2001 From: Chalo Salvador Date: Fri, 31 Jan 2025 10:20:50 +0100 Subject: [PATCH 2/2] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29bb2d..fef41174fc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1 @@ +- Fixes issue with custom 404 pages not being returned in Next.js in the emulator (#8035).