spacedrive/patches/@remix-run__router@1.13.1.patch
Vítor Vasconcellos 3428644a29
Fix server release (#2518)
* Adjust server Dockerfile
 - Simpify remix-run_router patch

* Update crun and podman required for new buildah version
 - Build arm64 version of server

* Disable arm64 build for now, build is too slow with qemu
2024-05-29 23:28:28 +00:00

64 lines
2.5 KiB
Diff

diff --git a/dist/router.cjs.js b/dist/router.cjs.js
index e9942914335495941766c9d1a63eacd42c67c6fc..2abfc267930e026e1a94f2c5c0fd6c5f88965802 100644
--- a/dist/router.cjs.js
+++ b/dist/router.cjs.js
@@ -1481,6 +1481,7 @@ const redirect = function redirect(url, init) {
}
let headers = new Headers(responseInit.headers);
headers.set("Location", url);
+ if (typeof init === "object" && init.replace) headers.set("X-Remix-Redirect-Replace", "true");
return new Response(null, _extends({}, responseInit, {
headers
}));
@@ -2491,7 +2492,7 @@ function createRouter(init) {
fetchRedirectIds.add(fetcherKey);
}
await startRedirectNavigation(state, redirect.result, {
- replace
+ replace: replace || redirect.result.replace
});
return {
shortCircuited: true
@@ -2698,7 +2699,9 @@ function createRouter(init) {
let fetcherKey = revalidatingFetchers[redirect.idx - matchesToLoad.length].key;
fetchRedirectIds.add(fetcherKey);
}
- return startRedirectNavigation(state, redirect.result);
+ return startRedirectNavigation(state, redirect.result, {
+ replace: redirect.result.replace
+ });
}
// Process and commit output from loaders
@@ -4121,6 +4124,7 @@ async function callLoaderOrAction(type, request, match, matches, manifest, mapRo
type: ResultType.redirect,
status,
location,
+ replace: result.headers.get("X-Remix-Redirect-Replace") !== null,
revalidate: result.headers.get("X-Remix-Revalidate") !== null,
reloadDocument: result.headers.get("X-Remix-Reload-Document") !== null
};
diff --git a/dist/utils.d.ts b/dist/utils.d.ts
index f393b6ca4f4092d1fe83348d8b2f1598bc63ef88..ef3eacc16b96c5d955c3beb202434bf491c0deed 100644
--- a/dist/utils.d.ts
+++ b/dist/utils.d.ts
@@ -38,6 +38,7 @@ export interface RedirectResult {
location: string;
revalidate: boolean;
reloadDocument?: boolean;
+ replace?: boolean;
}
/**
* Unsuccessful result from a loader or action
@@ -458,7 +459,9 @@ export declare class DeferredData {
}
export type DeferFunction = (data: Record<string, unknown>, init?: number | ResponseInit) => DeferredData;
export declare const defer: DeferFunction;
-export type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
+export type RedirectFunction = (url: string, init?: number | (ResponseInit & {
+ replace?: boolean;
+})) => Response;
/**
* A redirect response. Sets the status code and the `Location` header.
* Defaults to "302 Found".