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

throw redirect causes error with status code 500 on the client #6049

Closed
HanielU opened this issue Aug 18, 2022 · 4 comments
Closed

throw redirect causes error with status code 500 on the client #6049

HanielU opened this issue Aug 18, 2022 · 4 comments

Comments

@HanielU
Copy link

HanielU commented Aug 18, 2022

Describe the bug

The /user/close/[plan]/+page.svelte with a +page.ts & load function that looks like this

import type { PageLoad } from "./$types";
import { get as getStoreValue } from "svelte/store";
import { redirect } from "@sveltejs/kit";
import { browser } from "$app/env";

export const load: PageLoad = () => {
  throw redirect(301, "/user");
};

returns an error with status code 500 when navigated to like this <a href="/user/close/magik">here</a>

But It redirects correctly on window refresh...

Reproduction

Here is a repo https://github.com/HanielU/kit-redirect-issue

Install dependencies

yarn

Start dev server

yarn dev

Logs

No Response

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (4) x64 Intel(R) Core(TM) i5-3437U CPU @ 1.90GHz
    Memory: 1.60 GB / 7.87 GB
  Binaries:
    Node: 16.15.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.15 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.5.5 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.71)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.64
    @sveltejs/kit: ^1.0.0-next.422 => 1.0.0-next.422
    svelte: ^3.44.0 => 3.49.0
    vite: ^3.0.0 => 3.0.8

Severity

serious, but I can work around it

Additional Information

No response

@HanielU HanielU changed the title throw redirect causes error with status code 500 throw redirect causes error with status code 500 on the client Aug 18, 2022
@Rich-Harris
Copy link
Member

This looks like a duplicate of #5952 — closing

@maximedupre
Copy link

@Rich-Harris This seems like a different issue.

I'm on 1.0.0-next.454 and throw redirect(302, '/') results in a 500 error if the navigation isn't made with the client router (e.g. it only occurs if you access the page directly).

The error gets captured in handleError{ status: 302, location: '/' }

@maximedupre
Copy link

@Rich-Harris @Conduitry Is it possible to reopen this issue? :)

@Conduitry
Copy link
Member

This issue is a duplicate of #5952. If the issue you're having is a server-side redirect that's not working, that would be a separate issue, because this one is about client-side redirects. If you have a minimal reproduction, you should open a separate issue for it.

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

4 participants