gateway: serve the SPA bundle same-origin (#1444)
New spa/serve-spa.ts: @fastify/static with wildcard:false plus a GET /* catch-all that returns index.html for non-backend paths and a JSON 404 for unknown /api, /mcp, /socket.io paths. WEB_DIST_DIR unset disables serving (dev uses the Vite dev server, which proxies to the gateway); set but invalid fails loud at boot. A wildcard route, not setNotFoundHandler: Nest installs its own not-found handler at init and Fastify allows only one. find-my-way matches most-specific-first, so declared routes win over the catch-all. Cache semantics stay the library default (max-age=0 + ETag revalidation); immutable hashed-asset caching is deferred to P6. gateway.Dockerfile builds the web bundle and ships it at /app/web-dist with WEB_DIST_DIR set.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^0.80.0",
|
||||
"@fastify/helmet": "^13.0.2",
|
||||
"@fastify/static": "^8.3.0",
|
||||
"@mariozechner/pi-ai": "^0.65.0",
|
||||
"@mariozechner/pi-coding-agent": "^0.65.0",
|
||||
"@modelcontextprotocol/sdk": "^1.27.1",
|
||||
|
||||
Reference in New Issue
Block a user