pull out serve static assets methods

This commit is contained in:
Evan Almloff committed 2023-05-02 11:05:21 -05:00
1 parent e6c540320e
commit fb6757484d
4 files changed
+94 -36

No files matched your search

@@ -40,20 +40,16 @@ fn main() {
.unwrap()
.block_on(async move {
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 8080));
use tower_http::services::ServeDir;
// Serve the dist/assets folder with the javascript and WASM files created by the CLI
let serve_dir = ServeDir::new("dist/assets");
axum::Server::bind(&addr)
.serve(
axum::Router::new()
// Serve the dist/assets folder with the javascript and WASM files created by the CLI
.serve_static_assets("./dist")
// Register server functions
.register_server_fns("")
// Connect to the hot reload server
.connect_hot_reload()
// Serve the static assets folder
.nest_service("/assets", serve_dir)
// If the path is unknown, render the application
.fallback(
move |uri: http::uri::Uri, State(ssr_state): State<SSRState>| {