server: Make sure to fallback to the app when an unknown file is encountered

This commit is contained in:
traxys 2023-06-29 15:28:01 +02:00
parent 2ac56e2e7f
commit 47e4eed1a9

View file

@ -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}");