forked from clearml/clearml-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.config.js
More file actions
44 lines (39 loc) · 983 Bytes
/
Copy pathproxy.config.js
File metadata and controls
44 lines (39 loc) · 983 Bytes
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const fs = require('fs');
const targets = [
'https://api.trains-master.hosted.allegro.ai', // 1
];
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;