INNER CODE UNIT · Python
send_wrapper
ArcReel/ArcReel · server/app.py:755
async def send_wrapper(message: Message) -> None:
if message["type"] == "http.response.start":
headers = MutableHeaders(scope=message)
if headers.get("content-type", "").lower().startswith("text/html"):
headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0"
await send(message)
await self.app(scope, receive, send_wrapper)
app.add_middleware(SPAShellNoCacheMiddleware)
# 前端构建产物:SPA 静态文件服务。fallback 仅对 GET/HEAD 生效,写请求误入页面路径不再返回页面。
# 挂载条件必须检查 index.html 而非目录:app.frontend 在启动期校验 fallback 文件,
# 构建产物不完整时会抛 RuntimeError 拖垮整个应用(含全部 API)
frontend_dist_dir = PROJECT_ROOT / "frontend" / "dist"