from fastapi import FastAPI, Response from pydantic import BaseSettings from fastapi.staticfiles import StaticFiles class Settings(BaseSettings): dev_mode: bool = False settings = Settings() app = FastAPI() if settings.dev_mode: import httpx @app.get("/{path:path}") async def proxy(path: str, response: Response): async with httpx.AsyncClient() as client: proxy = await client.get(f"http://localhost:3000/{path}") response.body = proxy.content response.status_code = proxy.status_code return response else: app.mount("/", StaticFiles(directory="frontend", html=True), name="frontend")