forked from influxdata/chronograf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.proxyrc.js
29 lines (28 loc) · 863 Bytes
/
.proxyrc.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 no-console: 0 */
const { createProxyMiddleware } = require("http-proxy-middleware");
module.exports = function (app) {
const handleProxyError = err => {
if (err.code === "ECONNREFUSED") {
console.log(
"Cannot reach Chronograf server at localhost:8888. Is it running?"
);
} else {
console.log(`Error: ${err.code}`);
}
};
const proxyMiddleware = createProxyMiddleware("/chronograf/v1", {
target: "http://localhost:8888",
logLevel: "silent",
changeOrigin: true,
onError: handleProxyError,
});
const proxyMiddlewareOAuth = createProxyMiddleware("/oauth", {
target: "http://localhost:8888",
logLevel: "silent",
changeOrigin: true,
onError: handleProxyError,
});
const port = Number(process.env.PORT || 8080);
app.use(proxyMiddleware);
app.use(proxyMiddlewareOAuth);
};