How a Cloudflare Worker Fix Stopped React SPA from Swallowing API Redirect Routes
A developer building the Jo4 platform discovered that affiliate tracking links at /go/* were returning the full React single-page application instead of the intended 302 redirect responses. The issue stemmed from Cloudflare's default SPA behavior, which serves index.html for any path not matching a static file, intercepting the requests before they could reach the backend API at jo4-api.jo4.io. As a result, affiliate clicks went unrecorded and partner traffic was lost entirely. The fix involved adding routing logic inside a Cloudflare Worker to intercept /go/* paths at the network edge and proxy them directly to the backend API, bypassing the SPA bundle. Using the redirect: 'manual' option ensured the 302 response was passed through to the browser rather than being resolved by the Worker itself.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in