-
Couldn't load subscription status.
- Fork 1.4k
Description
Which component is affected?
Qwik City
Describe the bug
On the static and Cloudflare adapters (and most likely all others with SSG capabilities), SPA <Link> routing results in a full page reload unless origin is set the adapter's vite.config.ts, and the actual origin matches it.
This issue affects both v1 and v2.
Assuming your SSG settings have an origin of http://localhost:3000:
If you visit http://localhost:3000 (origin match) from your browser, <Link> SPA routing and useNavigate will work properly.
If you visit http://127.0.0.1:3000 (origin mismatch) from your browser, Clicking a <Link> will result in a full page reload, as if it was a plain <a>. Calls to useNavigate will work, but using the browser history back and forward buttons will result in full page reloads.
This is a problem because this makes using preview environments (like on workers.dev) or local testing of prod builds impossible. It also makes it impossible to serve the same application from multiple domains, like serving on both a domain and the www subdomain of that domain. Using <Link> and useNavigate with relative paths should not depend on a specific origin.
Thank you!
Reproduction
https://github.com/termermc/qwik-spa-bug-repro
Steps to reproduce
- Create a new Qwik City app
- Add add the static adapter
- Edit the origin in the adapter's
vite.config.tstohttp://localhost:3000 - Add some
<Link>components to navigate between different pages - Build the project with
pnpm run build - Start a webserver listening on
0.0.0.0:3000at the root of dist - Visit
http://localhost:3000, notice clicking links uses SPA routing - Visit
http://127.0.0.1:3000, notice clicking links causes full page reloads
System Info
System:
OS: Linux 6.17 Arch Linux
CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
Memory: 89.55 GB / 125.72 GB
Container: Yes
Shell: 4.1.2 - /usr/bin/fish
Binaries:
Node: 24.9.0 - /usr/sbin/node
Yarn: 1.22.22 - /usr/sbin/yarn
npm: 11.6.2 - /usr/sbin/npm
pnpm: 10.18.3 - /usr/sbin/pnpm
bun: 1.3.1 - /home/termer/.bun/bin/bun
Deno: 2.5.1 - /home/termer/.deno/bin/deno
Browsers:
Firefox: 144.0
Firefox Developer Edition: 144.0Additional Information
No response