Skip to content

Commit

Permalink
Handle 404 status code in the proxyResponse. (#8119)
Browse files Browse the repository at this point in the history
* Handle 404 status code in the proxyResponse.

* Changelog

---------

Co-authored-by: Leonardo Ortiz <[email protected]>
  • Loading branch information
chalosalvador and leoortizz authored Jan 31, 2025
1 parent 468000f commit 60f3cd7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixes issue with custom 404 pages not being returned in Next.js in the emulator (#8035).
7 changes: 6 additions & 1 deletion src/frameworks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand Down

0 comments on commit 60f3cd7

Please sign in to comment.