fix: keep SPA fallback for non-api paths but 404 unmatched /api routes

This commit is contained in:
2026-09-21 21:39:09 +02:00
parent b5e1c4b42a
commit 9e69730bfd
+7 -1
View File
@@ -20,6 +20,10 @@ mod note;
mod status; mod status;
mod store; mod store;
async fn api_not_found() -> axum::http::StatusCode {
axum::http::StatusCode::NOT_FOUND
}
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
dotenv().ok(); dotenv().ok();
@@ -39,7 +43,9 @@ async fn main() {
.nest("/notes", notes_routes) .nest("/notes", notes_routes)
.merge(status_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 index = format!("{}{}", config::FRONTEND_PATH.to_string(), "/index.html");
let serve_dir = let serve_dir =