fix: preserve partial search param through redirects (#3715)
## Summary - Fixes #2610 — "Partial + redirect breaks islands" - When a partial request (`?fresh-partial=true`) hits a server-side redirect via `ctx.redirect()`, the `fresh-partial` search param is now preserved in the redirect `Location` header - Previously the param was lost, so the redirect target rendered as a full page instead of a partial response, breaking island hydration The fix is in `ctx.redirect()` in `packages/fresh/src/context.ts` — when `this.isPartial` is true, the partial param is appended to the redirect location (handling existing query params and hash fragments correctly). Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
0015710909
commit
4e0331b5c9
@@ -182,6 +182,16 @@ export class Context<State> {
|
||||
location = `${pathname.replaceAll(/\/+/g, "/")}${search}`;
|
||||
}
|
||||
|
||||
// Preserve the partial search param through redirects so that the
|
||||
// redirected page is still rendered in partial mode.
|
||||
if (this.isPartial) {
|
||||
const hashIdx = location.indexOf("#");
|
||||
const base = hashIdx > -1 ? location.slice(0, hashIdx) : location;
|
||||
const hash = hashIdx > -1 ? location.slice(hashIdx) : "";
|
||||
const separator = base.includes("?") ? "&" : "?";
|
||||
location = `${base}${separator}${PARTIAL_SEARCH_PARAM}=true${hash}`;
|
||||
}
|
||||
|
||||
return new Response(null, {
|
||||
status,
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user