const fs = require("fs"); const proxy = require("http-proxy-middleware"); let config = {url: "http://10.12.121.228:8100/"}; try { const data = fs.readFileSync("./proxy.json", "utf-8"); config = JSON.parse(data) } catch(err) { console.error("Failed to load proxy.json in project root"); } module.exports = function(app) { app.use(proxy('/api/ws', { target: config.url, ws: true })); app.use(proxy('/api', { target: config.url, ws: false })); };