Skip to content

Instantly share code, notes, and snippets.

@kiliman
Created December 8, 2021 16:41
Show Gist options
  • Save kiliman/c1e1dc34324a500f0cffd1fef4d87ad4 to your computer and use it in GitHub Desktop.
Save kiliman/c1e1dc34324a500f0cffd1fef4d87ad4 to your computer and use it in GitHub Desktop.
PATCH to add request and context to Remix CatchBoundary
diff --git a/node_modules/@remix-run/server-runtime/server.js b/node_modules/@remix-run/server-runtime/server.js
index eef3403..d483581 100644
--- a/node_modules/@remix-run/server-runtime/server.js
+++ b/node_modules/@remix-run/server-runtime/server.js
@@ -226,7 +226,9 @@ async function handleDocumentRequest(request, loadContext, build, platform, rout
componentDidCatchEmulator.catch = {
status: requestState === "no-match" ? 404 : 405,
statusText: requestState === "no-match" ? "Not Found" : "Method Not Allowed",
- data: null
+ data: null,
+ request: { method: request.method, url: request.url },
+ context: loadContext,
};
} else if (isActionRequest(request)) {
let actionMatch = matches[matches.length - 1];
@@ -263,7 +265,9 @@ async function handleDocumentRequest(request, loadContext, build, platform, rout
componentDidCatchEmulator.catch = {
status: actionResponse.status,
statusText: actionResponse.statusText,
- data: await data.extractData(actionResponse.clone())
+ data: await data.extractData(actionResponse.clone()),
+ request: { method: request.method, url: request.url },
+ context: loadContext,
};
} // If we did not match a route, there is no need to call any loaders
@@ -345,7 +349,9 @@ async function handleDocumentRequest(request, loadContext, build, platform, rout
componentDidCatchEmulator.catch = {
status: response.status,
statusText: response.statusText,
- data: await data.extractData(response.clone())
+ data: await data.extractData(response.clone()),
+ request: { method: request.method, url: request.url },
+ context: loadContext,
};
routeLoaderResults[index] = responses.json(null, {
status: response.status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment