Spaces:
Sleeping
Sleeping
visilog
Browse files- server/main.py +9 -5
server/main.py
CHANGED
|
@@ -78,8 +78,12 @@ app.add_middleware(
|
|
| 78 |
# --- Static File Serving for Production ---
|
| 79 |
# This must come *after* the API routes to avoid conflicts.
|
| 80 |
|
| 81 |
-
#
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
#
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
# --- Static File Serving for Production ---
|
| 79 |
# This must come *after* the API routes to avoid conflicts.
|
| 80 |
|
| 81 |
+
# 1. Mount the '/assets' directory for Vite's bundled JS and CSS.
|
| 82 |
+
app.mount("/assets", StaticFiles(directory="static/assets"), name="assets")
|
| 83 |
+
|
| 84 |
+
# 2. A final catch-all route for SPA routing.
|
| 85 |
+
# This is only triggered if a file is not found in the mounted directories above.
|
| 86 |
+
# It serves the main HTML file, allowing React Router to handle the path.
|
| 87 |
+
@app.get("/{full_path:path}")
|
| 88 |
+
async def serve_react_app(full_path: str):
|
| 89 |
+
return FileResponse("static/index.html")
|