Skip to content

fix(navigation): reuse the redirected response instead of refetching - #578

Merged
cpojer merged 1 commit into
voidzero-dev:mainfrom
MaxtuneLee:fix/redirect-duplicate-get
Oct 26, 2026
Merged

cpojer merged 1 commit into
voidzero-dev:mainfrom
MaxtuneLee:fix/redirect-duplicate-get

Conversation

@MaxtuneLee

Copy link
Copy Markdown
Contributor

summary

Close #560

When a visit receives a redirect for example 303 see other, the browser automatically follows the redirect by issuing a GET request to the URL specified in the Location header, and return the final GET response. loadNavigationShell() detected response.redirected and then called itself again with GET, so the destination was requested a second time and the first response was thrown away.

This could also produce inconsistent results when the destination depends on server-side state.

This PR refactors the redirect handling so that it updates the local state (method, fetchUrl, url, and commitTarget) to point to the final destination, continuing through the standard parsing and rendering pipeline using the existing response.

Files touched

  • packages/void/src/pages/navigation-engine.ts: replace the recursive loadNavigationShell() call in the response.redirected branch with state update that reuses the existing response.
  • packages/void/test/unit/pages-client.test.ts: update "follows a same-host Capacitor action redirect in place" so the redirected response carries real page data and the test asserts fetch is called once. (It previously asserted the second GET)

Test plan

  • vp test run packages/void/test/unit/pages-client.test.ts (67 passed)

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@cpojer
cpojer merged commit 89152bd into voidzero-dev:main Oct 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

POST → 303 redirect triggers a duplicate GET request to the destination

2 participants