-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.js
More file actions
33 lines (26 loc) · 805 Bytes
/
Copy pathproxy.js
File metadata and controls
33 lines (26 loc) · 805 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
26
27
28
29
30
31
32
33
const express = require('express');
const cors = require('cors');
const { createProxyMiddleware } = require('http-proxy-middleware');
const app = express();
const port = 3000;
// Enable CORS for all routes
app.use(cors());
// Serve static files
app.use(express.static('src/frontend'));
// Proxy middleware configuration
const apiProxy = createProxyMiddleware({
target: 'https://api.vybenetwork.xyz',
changeOrigin: true,
pathRewrite: {
'^/api': '' // Remove /api prefix when forwarding
},
onProxyRes: function (proxyRes, req, res) {
proxyRes.headers['Access-Control-Allow-Origin'] = '*';
}
});
// Use proxy for all /api/* requests
app.use('/api', apiProxy);
app.listen(port, () => {
console.log(`Proxy server running at http://localhost:${port}`);
});
//