From 5610260120aa61c85ec583655758e499bf3de434 Mon Sep 17 00:00:00 2001 From: itsscb Date: Tue, 4 Mar 2025 23:42:48 +0100 Subject: [PATCH] fix: update fallback service to serve index.html for not found routes --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1f0d2f5..a67ea98 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,13 @@ use axum::Router; -use tower_http::services::ServeDir; +use tower_http::services::{ServeDir, ServeFile}; #[shuttle_runtime::main] #[allow(clippy::unused_async)] async fn main() -> shuttle_axum::ShuttleAxum { - let router = Router::new().fallback_service(ServeDir::new("frontend/dist/frontend/browser")); + let router = Router::new().fallback_service( + ServeDir::new("frontend/dist/frontend/browser") + .not_found_service(ServeFile::new("frontend/dist/frontend/browser/index.html")), + ); Ok(router.into()) }