Modify server/node-build.ts to bind to host "0.0.0.0" and use port 5000 for production deployments. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9203795e-937a-4306-b81d-b4d5c78c240e Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: b9d17033-bdc5-48c2-8dbe-b1b7c3faf64a Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7c94b7a0-29c7-4f2e-94ef-44b2153872b7/9203795e-937a-4306-b81d-b4d5c78c240e/qPXTzuE Replit-Helium-Checkpoint-Created: true
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import path from "path";
|
|
import { createServer } from "./index";
|
|
import * as express from "express";
|
|
|
|
const app = createServer();
|
|
const port = process.env.PORT || 5000;
|
|
const host = "0.0.0.0";
|
|
|
|
// In production, serve the built SPA files
|
|
const __dirname = import.meta.dirname;
|
|
const distPath = path.join(__dirname, "../spa");
|
|
|
|
// Serve static files
|
|
app.use(express.static(distPath));
|
|
|
|
// Handle React Router - serve index.html for all non-API routes
|
|
app.get("*", (req, res) => {
|
|
// Don't serve index.html for API routes
|
|
if (req.path.startsWith("/api/") || req.path.startsWith("/health")) {
|
|
return res.status(404).json({ error: "API endpoint not found" });
|
|
}
|
|
|
|
res.sendFile(path.join(distPath, "index.html"));
|
|
});
|
|
|
|
app.listen(Number(port), host, () => {
|
|
console.log(`🚀 AeThex server running on ${host}:${port}`);
|
|
console.log(`📱 Frontend: http://${host}:${port}`);
|
|
console.log(`🔧 API: http://${host}:${port}/api`);
|
|
});
|
|
|
|
// Graceful shutdown
|
|
process.on("SIGTERM", () => {
|
|
console.log("🛑 Received SIGTERM, shutting down gracefully");
|
|
process.exit(0);
|
|
});
|
|
|
|
process.on("SIGINT", () => {
|
|
console.log("🛑 Received SIGINT, shutting down gracefully");
|
|
process.exit(0);
|
|
});
|