Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Page load function doesn't respect redirect during SSR #5669

Closed
moatra opened this issue Jul 22, 2022 · 1 comment
Closed

Error Page load function doesn't respect redirect during SSR #5669

moatra opened this issue Jul 22, 2022 · 1 comment

Comments

@moatra
Copy link
Contributor

moatra commented Jul 22, 2022

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

@moatra moatra changed the title Error Page Load Function Doesn't Respect Redirect When SSR'd Error Page load function doesn't respect redirect during SSR Jul 22, 2022
@Rich-Harris
Copy link
Member

Closing as outdated since #5748+error.svelte files can no longer load data, which means redirect logic must be implemented elsewhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants