clearml-web/proxy.config.mjs

47 lines
1012 B
JavaScript
Raw Normal View History

import * as fs from 'fs';
2021-01-18 14:30:25 +00:00
const targets = [
'http://localhost:8008', // 1
2021-01-18 14:30:25 +00:00
];
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] = {
2021-01-18 14:30:25 +00:00
target: target,
secure: true,
2021-01-18 14:30:25 +00:00
changeOrigin: true,
cookieDomainRewrite: 'localhost',
logLevel: 'debug',
2021-01-18 14:30:25 +00:00
pathRewrite: {
[`^${path}`]: ''
2021-01-18 14:30:25 +00:00
}
};
});
export default PROXY_CONFIG;