From 7cd5c540f513fd6338ca26e15f95623efaac9d85 Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Wed, 11 Dec 2024 13:39:10 -0500 Subject: [PATCH] Throw single fetch redirects fetched from the server (#12506) --- .changeset/dry-toes-sneeze.md | 5 +++++ packages/react-router/lib/dom/ssr/single-fetch.tsx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/dry-toes-sneeze.md diff --git a/.changeset/dry-toes-sneeze.md b/.changeset/dry-toes-sneeze.md new file mode 100644 index 0000000000..e93a21191f --- /dev/null +++ b/.changeset/dry-toes-sneeze.md @@ -0,0 +1,5 @@ +--- +"react-router": patch +--- + +Throw unwrapped single fetch redirect to align with pre-single fetch behavior diff --git a/packages/react-router/lib/dom/ssr/single-fetch.tsx b/packages/react-router/lib/dom/ssr/single-fetch.tsx index 7829b400ca..301d29428b 100644 --- a/packages/react-router/lib/dom/ssr/single-fetch.tsx +++ b/packages/react-router/lib/dom/ssr/single-fetch.tsx @@ -522,7 +522,7 @@ function unwrapSingleFetchResult(result: SingleFetchResult, routeId: string) { if (result.replace) { headers["X-Remix-Replace"] = "yes"; } - return redirect(result.redirect, { status: result.status, headers }); + throw redirect(result.redirect, { status: result.status, headers }); } else if ("data" in result) { return result.data; } else {