feat: add SPA, serve at /app/, update Dockerfile and README
- React + TanStack Router + shadcn/ui SPA under spa/ - serve spa/dist at /app/ with index.html fallback for client routing - Dockerfile: node build stage for SPA, copy dist into runtime image - README: document SPA, CORS_ORIGINS env var, architecture entry - vite base set to /app/, manifest.json paths fixed
This commit is contained in:
@@ -2,7 +2,11 @@ use std::num::NonZeroU32;
|
||||
|
||||
use axum::{Router, routing};
|
||||
use axum_governor::{GovernorConfigBuilder, GovernorLayer, Quota, extractor::PeerIp};
|
||||
use tower_http::{cors::CorsLayer, services::ServeDir, trace::TraceLayer};
|
||||
use tower_http::{
|
||||
cors::CorsLayer,
|
||||
services::{ServeDir, ServeFile},
|
||||
trace::TraceLayer,
|
||||
};
|
||||
|
||||
use crate::{handlers, state::AppState};
|
||||
|
||||
@@ -22,6 +26,10 @@ pub fn build_router(state: AppState, ap_router: Router) -> Router {
|
||||
.merge(html_routes(rate_limit))
|
||||
.merge(api_routes(rate_limit))
|
||||
.nest_service("/static", ServeDir::new("static"))
|
||||
.nest_service(
|
||||
"/app",
|
||||
ServeDir::new("spa/dist").fallback(ServeFile::new("spa/dist/index.html")),
|
||||
)
|
||||
.layer(TraceLayer::new_for_http())
|
||||
.with_state(state)
|
||||
.merge(ap_router)
|
||||
|
||||
Reference in New Issue
Block a user