Skip to content

Commit 60f3cd7

Browse files
Handle 404 status code in the proxyResponse. (#8119)
* Handle 404 status code in the proxyResponse. * Changelog --------- Co-authored-by: Leonardo Ortiz <[email protected]>
1 parent 468000f commit 60f3cd7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixes issue with custom 404 pages not being returned in Next.js in the emulator (#8035).

src/frameworks/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,12 @@ export function simpleProxy(hostOrRequestHandler: string | RequestHandler) {
208208
originalRes.end();
209209
});
210210
} else {
211-
const proxiedRes = proxyResponse(originalReq, originalRes, next);
211+
const proxiedRes = proxyResponse(originalReq, originalRes, () => {
212+
// This next function is called when the proxied response is a 404
213+
// In that case we want to let the handler to use the original response
214+
void hostOrRequestHandler(originalReq, originalRes, next);
215+
});
216+
212217
await hostOrRequestHandler(originalReq, proxiedRes, next);
213218
}
214219
};

0 commit comments

Comments
 (0)