-
Notifications
You must be signed in to change notification settings - Fork 375
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
[Bug?]: throwing redirect in route load function is not handled #1543
Comments
So a couple things you need to do. You need to return instead of throw the redirect. Secondly you need to wrap in the cache function. Also you need to call the function in createAsync() const loadData = cache(() => {
'use server'
return redirect('/about')
}, "load-data");
export const route = {
load: () => loadData()
}
export default function Home() {
const data = createAsync(() => loadData());
} |
Throwing the redirect also works, but the important part is calling |
I feel this is intended behavior at the moment. Thinking we can probably close this issue? |
What if I don't want to cache the request? For example, if I want to validate some auth-link with some hash parameter, and then want to redirect user. I don't think I want to cache the response in this case. |
Use |
Can I use
I also, don't want to cash that response, so if link is clicked twice, it is no longer valid |
Yeah that should work fine |
So should it be like this:
|
Yeah this is by design since the I think an action is fine, but I think |
Duplicates
Latest version
Current behavior 😯
I'm trying to throw a redirect in the route load function:
When I try to navigate to that page, instead of redirecting, it throws a server error:
Expected behavior 🤔
It should redirect me to the page in the redirect
Steps to reproduce 🕹
I created a repository with an example: https://github.com/maksimsemenov/solid-start-redirect?tab=readme-ov-file
Steps to reproduce:
/
route.Context 🔦
I initiated project with
npm init solid@latest
.I also tried just to return
redirect
instead of throwing it. In this case there is no server error, but no redirect either.I found a few similar issues that are are resolved. But it seems that the issue is back
Your environment 🌎
The text was updated successfully, but these errors were encountered: