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

Add <Redirect /> component #412

Closed
2 tasks
Bechma opened this issue Jan 30, 2023 · 0 comments
Closed
2 tasks

Add <Redirect /> component #412

Bechma opened this issue Jan 30, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Bechma
Copy link
Contributor

Bechma commented Jan 30, 2023

Motivation

We need to increase the compatibility of SSR redirects from server functions:

Problem

With axum in the backend as an example, the redirects emitted from the server functions with an utility like leptos_axum::redirect(cx, path) makes a request in the browser, but it doesn't redirects in the application(wasm).

To accomplish that, we need to not do a redirect, but instead, create a Response case that handle that in the client. Something like:

let navigate = use_navigate(cx);
match msg {
...
  Ok(EditorResponse::Redirect) => navigate("/login", NavigateOptions::default()).unwrap(),
...
}

What we really want is to keep the redirect from the server fn(so in case there is no wasm or js, the redirect will still do his job) and handle it in the client.

Solution

A <Redirect /> component for the integrations:

  • Axum
  • Actix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants