Skip to content

fix: MCD-1270 Keep redirect payloads in the page cache so SPA repeat visits follow CE-API redirects.#509

Open
drubot wants to merge 1 commit into
2.xfrom
feature/mcd-1270-spa-redirect
Open

fix: MCD-1270 Keep redirect payloads in the page cache so SPA repeat visits follow CE-API redirects.#509
drubot wants to merge 1 commit into
2.xfrom
feature/mcd-1270-spa-redirect

Conversation

@drubot

@drubot drubot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

CE-API redirects were not followed on repeat SPA visits to a redirected path: the URL stayed on the source path and the previously mounted page remained visible (MOP-571, observed on beta.vegan.at /newsletter/inhalt/newsletter-anmeldung).

Root cause

Not a navigation race (the imperative navigateTo() in fetchPage() wins fine, first visits always work): after handling a redirect, fetchPage() did pageRef.value = createEmptyPage(). pageRef is the useFetch data ref bound to the payload cache entry of the redirect source path, so this overwrote the cached redirect payload with an empty page. On every subsequent SPA visit to the path, fetchPage() served the poisoned cache entry — no redirect key, no navigation, empty page under the source URL, previous page effectively still visible.

Reproduced live on beta.vegan.at: first SPA visit to /newsletter follows the redirect, second visit strands on /newsletter with the Startseite title. Reproduced the same in the playground e2e (red without this fix, green with it).

Fix

Return a detached ref(createEmptyPage()) from the redirect branch instead of writing the empty page through into the payload cache. The cache retains the redirect payload, so repeat visits re-run the redirect handling. SSR (real 301) and external redirects unchanged.

Tests

  • New browser e2e in test/e2e/redirect.test.ts: SPA navigation to a redirecting path, twice (the repeat visit is the regression case). Verified red on unfixed 2.x, green with the fix.
  • Playground: /redirect-to-3 CE-API route + main-menu entry to click.
  • Full suite npm test: 124 passed (one unrelated suite flaked on a busy port, passes in isolation). Pre-existing lint errors on 2.x untouched.

Refs: MCD-1270


Drafted with Claude Code from claude-vm-3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants