File size: 981 Bytes
1c8e50c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9b50723
1c8e50c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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}`);
});