k-l-lambda Claude commited on
Commit
55a6cd7
·
1 Parent(s): 001aa74

fix(docker): add path.extname check to SPA catch-all route

Browse files

The inline docker-entry.ts now skips files with extensions (.onnx, .wasm),
allowing static middleware to serve them correctly. This fixes ONNX model
loading on HF Space which was incorrectly returning index.html.

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (1) hide show
  1. Dockerfile +1 -1
Dockerfile CHANGED
@@ -38,7 +38,7 @@ app.use(cors()); \
38
  app.use(express.json()); \
39
  app.use(express.static("app/dist")); \
40
  app.get("/health", (req, res) => res.json({status: "ok", timestamp: new Date().toISOString()})); \
41
- app.get("*", (req, res, next) => { if (req.path.startsWith("/health") || req.path.startsWith("/socket.io")) return next(); res.sendFile("app/dist/index.html", {root: "/app"}); }); \
42
  io.on("connection", (socket) => { console.log("Client connected:", socket.id); setupSocketHandlers(io, socket, gameManager); socket.on("disconnect", () => console.log("Client disconnected:", socket.id)); }); \
43
  httpServer.listen(PORT, "0.0.0.0", () => console.log("Server running on port " + PORT));' > docker-entry.ts
44
 
 
38
  app.use(express.json()); \
39
  app.use(express.static("app/dist")); \
40
  app.get("/health", (req, res) => res.json({status: "ok", timestamp: new Date().toISOString()})); \
41
+ app.get("*", (req, res, next) => { if (req.path.startsWith("/health") || req.path.startsWith("/socket.io")) return next(); const path = require("path"); if (path.extname(req.path)) return next(); res.sendFile("app/dist/index.html", {root: "/app"}); }); \
42
  io.on("connection", (socket) => { console.log("Client connected:", socket.id); setupSocketHandlers(io, socket, gameManager); socket.on("disconnect", () => console.log("Client disconnected:", socket.id)); }); \
43
  httpServer.listen(PORT, "0.0.0.0", () => console.log("Server running on port " + PORT));' > docker-entry.ts
44