-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (20 loc) · 823 Bytes
/
server.js
File metadata and controls
25 lines (20 loc) · 823 Bytes
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
const express = require("express");
const path = require("path");
const { createProxyMiddleware } = require("http-proxy-middleware");
const app = express();
const PORT = process.env.PORT || 8080;
const BACKEND_URL = process.env.BACKEND_URL ||
"https://resumedemobls-a7cja7bchqc7a8em.chilecentral-01.azurewebsites.net";
// Proxy API requests to the Azure backend
app.use("/api", createProxyMiddleware({
target: BACKEND_URL,
changeOrigin: true,
logLevel: "debug"
}));
// Serve React build folder
app.use(express.static(path.join(__dirname, "build")));
// Handle React routing, serve index.html for all other requests
app.use((req, res) => {
res.sendFile(path.join(__dirname, "build", "index.html"));
});
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));