Code Monkey home page Code Monkey logo

Comments (2)

Bechma avatar Bechma commented on June 7, 2024 1

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:
LEPTOS_OUTPUT_NAME=tailwind LEPTOS_SITE_ROOT=site LEPTOS_SITE_PKG_DIR=pkg LEPTOS_SITE_ADDR=127.0.0.1:8000 LEPTOS_RELOAD_PORT=3001 LEPTOS_LIB_DIR=. LEPTOS_BIN_DIR=. cargo build --package=leptos-tailwind --lib --target-dir=target/front --target=wasm32-unknown-unknown --no-default-features --features=hydrate

The error outputed is the one that joshua shared in the OP(from the SSR feature branch while compiling the hydrate feature)

from shuttle.

DougAnderson444 avatar DougAnderson444 commented on June 7, 2024

I'd love to use shuttle for an SSR'd Leptos site, watching this issue for progress 👍

from shuttle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.