mirror of
https://github.com/clearml/clearml-web
synced 2025-03-13 15:20:35 +00:00
43 lines
951 B
JavaScript
43 lines
951 B
JavaScript
const fs = require("fs");
|
|
|
|
const targets = ["http://13.201.173.241:8008"];
|
|
|
|
const PROXY_CONFIG = {
|
|
"^/version.json$": {
|
|
bypass: (req, res, proxyOptions) => {
|
|
let url;
|
|
if (req.url === "/version.json") {
|
|
url = "src/version.json";
|
|
} else if (req.url === "/configuration.json") {
|
|
url = "src/configuration.json";
|
|
} else if (req.url === "/onboarding.json") {
|
|
url = "src/onboarding.json";
|
|
} else {
|
|
return req.url;
|
|
}
|
|
|
|
const ver = fs.readFileSync(url);
|
|
res.writeHead(200, {
|
|
"Content-Length": ver.length,
|
|
"Content-Type": "application/json",
|
|
});
|
|
res.end(ver);
|
|
return true;
|
|
},
|
|
},
|
|
};
|
|
|
|
targets.forEach((target, i) => {
|
|
const path = `/service/${i + 1}/api`;
|
|
PROXY_CONFIG[path + "/*"] = {
|
|
target: target,
|
|
secure: false,
|
|
changeOrigin: true,
|
|
pathRewrite: {
|
|
[path]: "",
|
|
},
|
|
};
|
|
});
|
|
|
|
module.exports = PROXY_CONFIG;
|