const path = require('path'); const express = require('express'); const compression = require('compression'); const { createProxyMiddleware } = require('http-proxy-middleware'); const app = express(); const PORT = process.env.PORT ? Number(process.env.PORT) : 7860; const API_TARGET = process.env.INTERNAL_API_URL || 'http://127.0.0.1:8090'; app.use(compression()); const proxyMiddleware = createProxyMiddleware({ target: API_TARGET, changeOrigin: true, ws: true, // Keep the original /api prefix so routes still match the gateway expectations. logLevel: 'warn', }); app.use('/api', proxyMiddleware); const buildDir = path.join(__dirname, 'build'); app.use(express.static(buildDir, { maxAge: '1h', index: false })); app.get('*', (req, res) => { res.sendFile(path.join(buildDir, 'index.html')); }); app.listen(PORT, () => { // eslint-disable-next-line no-console console.log(`Task Management UI listening on port ${PORT}, proxying API to ${API_TARGET}`); });