Proxy to SvelteKit route auto-refreshes to 404
Describe the bug
When proxying a domain to a SvelteKit website, the router now re-executes the router which causes a 404. Example:
I have the SvelteKit website sveltekit.com. On proxy.com, I have a proxy which is an alias for sveltekit.com, except the root url proxy.com/ proxies to sveltekit.com/my-id.
This issue started happening in 1.0.0-next.577.
Reproduction
https://github.com/probablykasper/sveltekit-proxy-404-bug
Logs
No response
System Info
System:
OS: macOS 10.15.7
CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
Memory: 778.60 MB / 32.00 GB
Shell: 3.5.1 - /usr/local/bin/fish
Binaries:
Yarn: 3.3.0 - ~/Library/Application Support/Volta/tools/image/yarn/3.3.0/bin/yarn
npm: 8.19.2 - ~/Library/Application Support/Volta/tools/image/node/18.12.1/bin/npm
Browsers:
Brave Browser: 108.1.46.140
Chrome: 108.0.5359.124
Firefox: 107.0
Firefox Developer Edition: 109.0
Safari: 15.6.1
npmPackages:
@sveltejs/adapter-auto: ^1.0.0 => 1.0.0
@sveltejs/kit: ^1.0.1 => 1.0.1
svelte: ^3.55.0 => 3.55.0
vite: ^4.0.1 => 4.0.1
Severity
blocking an upgrade
Additional Information
Use case: At https://limey.io users can build their own pages, and connect custom domains to those pages. To make this possible, we have a Cloudflare Worker which proxies the custom domains to their respective pages.
I suspect that this line https://github.com/sveltejs/kit/blob/master/packages/kit/src/runtime/client/client.js#L1569 is the culprit. I'm not sure resolving that would fix it for all your cases though - what would happen if someone starts at a different sveltekit.com/X route and then does a client-side navigation to sveltekit.com/my-id, it would still fail, right?
I assume it would fail, but there's no client-side navigation to/from sveltekit.com/my-id, so haven't run into that. If that changes in the future, I'll need to think of a different solution
It's not ideal because it has some other effects (which may or may not affect you), but as a workaround you could try setting the embedded option to true (https://kit.svelte.dev/docs/configuration#embedded)
Nice, that workaround does the trick :)
The new reroute hook is a perfect alternative for my use case. Feel free to close this issue if there's no interest in fixing