mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-22 19:15:08 +03:00
Fix inter-services communication
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import express from 'express';
|
||||
import type { Request, Response } from 'express';
|
||||
import { createProxyMiddleware } from 'http-proxy-middleware';
|
||||
import { resolve } from 'path';
|
||||
|
||||
const app = express();
|
||||
const port = process.env.PORT || 3000;
|
||||
const port = Number(process.env.PORT) || 8301;
|
||||
const backendHost = process.env.BACKEND_HOST || "http://localhost:8300";
|
||||
const filePath = process.env.STATIC_FILE_PATH || ".";
|
||||
|
||||
@@ -15,14 +16,17 @@ app.use('/api', createProxyMiddleware({
|
||||
ws: true
|
||||
}));
|
||||
|
||||
// WebSockets are handled by the general API proxy above
|
||||
|
||||
// Serve static files
|
||||
app.use(express.static(resolve(filePath)));
|
||||
|
||||
// SPA routing - catch all handler for client-side routing
|
||||
app.use((_req, res) => {
|
||||
app.use((_req: Request, res: Response) => {
|
||||
res.sendFile(resolve(filePath, 'index.html'));
|
||||
});
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server launched on http://localhost:${port}`);
|
||||
app.listen(port, '0.0.0.0', () => {
|
||||
console.log(`Backend host: ${backendHost}`);
|
||||
console.log(`Server launched on http://0.0.0.0:${port}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user