Closed
Description
Describe the bug
If an error page's load
function returns a result with the redirect
property set, the redirect is honored during client side navigation, but not during SSR.
Reproduction
git clone git@github.com:moatra/svelte_error_redirect.git
cd svelte_error_redirect
npm install
npm run dev
Working: Client side navigation
Load http://localhost:5173
in a browser, and click on the the "dashboard" link. The client will eventually land on /login?from=/dashboard
due to the dashboard endpoint returning a 401 and the error page redirecting to the login page.
Not working: Server side rendering
Load http://localhost:5173/dashboard
in a new browser tab. The browser will get the Error Page html response instead of being redirected to /login?from=/dashboard
Logs
Logging the error that the `__error.svelte` load function receives:
Error: Failed to load data
at load_shadow_data (file:///home/thomas/Projects/svelte_repros/error_redirect/.svelte-kit/runtime/server/index.js:2705:18)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async load_node (file:///home/thomas/Projects/svelte_repros/error_redirect/.svelte-kit/runtime/server/index.js:2279:5)
at async respond$1 (file:///home/thomas/Projects/svelte_repros/error_redirect/.svelte-kit/runtime/server/index.js:2980:15)
at async resolve (file:///home/thomas/Projects/svelte_repros/error_redirect/.svelte-kit/runtime/server/index.js:3442:11)
at async respond (file:///home/thomas/Projects/svelte_repros/error_redirect/.svelte-kit/runtime/server/index.js:3386:20)
at async file:///home/thomas/Projects/svelte_repros/error_redirect/node_modules/@sveltejs/kit/dist/vite.js:2377:22
I believe that's expected due to `dasbhoard.js` always returning a 401 status.
System Info
error_redirect on main [!] is 📦 v0.0.1 via v18.6.0 took 4m41s
❯ npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"
System:
OS: Linux 5.17 Pop!_OS 22.04 LTS
CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Memory: 22.27 GB / 31.24 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 18.6.0 - ~/.nvm/versions/node/v18.6.0/bin/node
npm: 8.13.2 - ~/.nvm/versions/node/v18.6.0/bin/npm
Browsers:
Firefox: 102.0
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.63
@sveltejs/kit: next => 1.0.0-next.390
svelte: ^3.44.0 => 3.49.0
vite: ^3.0.0 => 3.0.2
Severity
blocking an upgrade
Additional Information
No response
Metadata
Metadata
Assignees
Labels
No labels