From 9e69730bfd2cef3081008b576570aee683c85e4f Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Mon, 21 Sep 2026 21:39:09 +0200 Subject: [PATCH] fix: keep SPA fallback for non-api paths but 404 unmatched /api routes --- packages/backend/src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/main.rs b/packages/backend/src/main.rs index a2cabc4..bbab6ec 100644 --- a/packages/backend/src/main.rs +++ b/packages/backend/src/main.rs @@ -20,6 +20,10 @@ mod note; mod status; mod store; +async fn api_not_found() -> axum::http::StatusCode { + axum::http::StatusCode::NOT_FOUND +} + #[tokio::main] async fn main() { dotenv().ok(); @@ -39,7 +43,9 @@ async fn main() { .nest("/notes", notes_routes) .merge(status_routes); - let api_routes = Router::new().nest("/v3", v3_routes); + let api_routes = Router::new() + .nest("/v3", v3_routes) + .fallback(api_not_found); let index = format!("{}{}", config::FRONTEND_PATH.to_string(), "/index.html"); let serve_dir =