-
Notifications
You must be signed in to change notification settings - Fork 253
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]: Leptos SSR feature doesn't work nicely with shuttle #1002
Comments
I just wanna mention a fix that tried to apply: // main.rs
cfg_if::cfg_if! {
if #[cfg(feature = "ssr")] {
#[shuttle_runtime::main]
async fn axum() -> shuttle_axum::ShuttleAxum {
use axum::{extract::Extension, routing::post, Router};
use leptos::*;
use leptos_axum::{generate_route_list, LeptosRoutes};
use leptos_tailwind::app::*;
use leptos_tailwind::fileserv::file_and_error_handler;
use std::sync::Arc;
// Setting get_configuration(None) means we'll be using cargo-leptos's env values
// For deployment these variables are:
// <https://github.com/leptos-rs/start-axum#executing-a-server-on-a-remote-machine-without-the-toolchain>
// Alternately a file can be specified such as Some("Cargo.toml")
// The file would need to be included with the executable when moved to deployment
let conf = get_configuration(Some("Cargo.toml")).await.unwrap();
let leptos_options = conf.leptos_options;
let routes = generate_route_list(|cx| view! { cx, <App/> }).await;
// build our application with a route
let app = Router::new()
.route("/api/*fn_name", post(leptos_axum::handle_server_fns))
.leptos_routes(leptos_options.clone(), routes, |cx| view! { cx, <App/> })
.fallback(file_and_error_handler)
.layer(Extension(Arc::new(leptos_options)));
Ok(app.into())
}
} else {
pub fn main() {
// no client-side main function
// unless we want this to work with e.g., Trunk for a purely client-side app
// see lib.rs for hydration function instead
}
}
} This code generation from the SSR should not be compiled in the frontend when the frontend is built with: The error outputed is the one that joshua shared in the OP(from the SSR feature branch while compiling the hydrate feature) |
I'd love to use shuttle for an SSR'd Leptos site, watching this issue for progress 👍 |
Hello @joshua-mo-143 & @ivancernja et al, I'm working on updating the Leptos book right now - I was just wondering if there's been any progress on resolving the Leptos SSR issue? It would be really great to include Shuttle in the Leptos book as a realistic deployment option for full Leptos apps - I know several people in the Leptos community have been asking & wondering about this..! Thanks! Daniel |
Hey everyone, apologies for the delayed answer. It looks like someone from Discord actually got Leptos working. You can find their notes as below, but be warned it's quite hacky: I made a repo for the project at https://github.com/x04/shuttle-leptos There are only really 2 files of interest: hacky stuff:
This issue is aimed to remain open until we can officially support Leptos through the new builder service that is being created. However, we are not exactly sure as to what the ETA is. |
Hello, thanks for the notes on this. Is there any way one could contribute to the builder service (or other changes required) i.e. is there a branch available or design notes? |
@atcol |
Is leptos support on the roadmap yet? Shuttle seems like a perfect fit for a leptos cloud? Edit: found the relevant issue which suggests this to be on the roadmap here: #1547 |
What happened?
repo link https://github.com/joshua-mo-143/lta
original thread link https://discord.com/channels/803236282088161321/1118239204850290729
using cargo shuttle 0.18.0 with dependencies at 0.18.0
when using
cargo run --no-default-features --features=ssr shuttle run
(or something similar) it just says the future can't be sent safely between threads:using cargo shuttle run returns this:
It looks like the codegen is being ran on top of the Leptos feature restriction meaning that the shuttle runtime macro runs into problems when trying to use the SSR feature.
Version
v0.18.0
Which operating system(s) are you seeing the problem on?
Linux
Which CPU architectures are you seeing the problem on?
x86_64
Relevant log output
Duplicate declaration
The text was updated successfully, but these errors were encountered: