-
Notifications
You must be signed in to change notification settings - Fork 2
/
setupProxy.js
29 lines (26 loc) · 952 Bytes
/
setupProxy.js
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
/* eslint-disable @typescript-eslint/no-var-requires */
const {createProxyMiddleware} = require("http-proxy-middleware");
let proxyConfig = null;
try {
if (process.env.PROXY) {
proxyConfig = JSON.parse(process.env.PROXY);
}
} catch (err) {
console.warn("PROXY environment not set", err);
}
// eslint-disable-next-line max-statements
module.exports = function (app) {
if (proxyConfig) {
proxyConfig.forEach((config) => {
app.use(config.path, createProxyMiddleware(config.options));
});
} else {
// Local
app.use("/api", createProxyMiddleware({changeOrigin: true, target: "http://localhost:9020/"}));
app.use("/api_module", createProxyMiddleware({changeOrigin: true, target: "http://localhost:9020/"}));
app.use(
"/notification",
createProxyMiddleware({changeOrigin: true, target: "http://localhost:9020/", ws: true}),
);
}
};