From 47e4eed1a9d836fcacd15c1628b2d13363f0cea0 Mon Sep 17 00:00:00 2001 From: traxys Date: Thu, 29 Jun 2023 15:28:01 +0200 Subject: [PATCH] server: Make sure to fallback to the app when an unknown file is encountered --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index a479ee8..ee53a3e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use jwt_simple::prelude::HS256Key; use migration::{Migrator, MigratorTrait}; use sea_orm::{ConnectOptions, Database, DatabaseConnection}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use tower_http::services::ServeDir; +use tower_http::services::{ServeDir, ServeFile}; use tracing_subscriber::EnvFilter; pub(crate) mod entity; @@ -130,7 +130,9 @@ async fn main() -> anyhow::Result<()> { let router = match config.serve_app { None => router, - Some(path) => router.fallback_service(ServeDir::new(path)), + Some(path) => router.fallback_service( + ServeDir::new(&path).fallback(ServeFile::new(path.join("index.html"))), + ), }; tracing::info!("Listening on {addr}");