Skip to content

Commit

Permalink
Fix proxy request typing bug and fallback 404 behavior in pages (#114)
Browse files Browse the repository at this point in the history
* Fix typing bug

* Add fallback 404 behavior
  • Loading branch information
GregBrimble authored Dec 15, 2021
1 parent e928f94 commit c7bee70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/long-ligers-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Patches typing mismatches between us, undici and miniflare when proxying requests in pages dev, and also adds fallback 404 behavior which was missed
5 changes: 4 additions & 1 deletion packages/wrangler/src/pages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,9 @@ const generateAssetsFetch = async (
deconstructedResponse.body = serveAsset(asset);
return deconstructedResponse;
}

deconstructedResponse.status = 404;
return deconstructedResponse;
};

let asset;
Expand Down Expand Up @@ -787,7 +790,7 @@ export const pages: BuilderCallback<unknown, unknown> = (yargs) => {
const url = new URL(request.url);
url.host = `127.0.0.1:${proxyPort}`;
request = new Request(url.toString(), request);
return await fetch(request);
return await fetch(request.url, request);
} catch (thrown) {
console.error(`Could not proxy request: ${thrown}`);

Expand Down

0 comments on commit c7bee70

Please sign in to comment.