require('dotenv').config({ path: '.env.production' });
const express = require('express');
const { createProxyMiddleware } = require('http-proxy-middleware');
const path = require('path');

const app = express();
console.log('start server')
app.use(
  '/auth',
  createProxyMiddleware({
    target: process.env.VITE_APP_AUTH_PROXY_HOST,
    changeOrigin: true,
  }),
);
app.use(
  '/api',
  createProxyMiddleware({
    target: process.env.VITE_APP_API_PROXY_HOST,
    changeOrigin: true,
  }),
);

app.use(express.static(path.join(__dirname, 'build')));

app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

app.listen(8089, () => {
  console.log('Server is running on port 8089');
});
