forked from GreggJuanEduardoPH/ngx-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy.conf.js
72 lines (70 loc) · 1.67 KB
/
proxy.conf.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const rewriteFn = (path, req) => {
switch (true) {
case path.startsWith('/back1/api'):
return path.replace('/back1/api', '/api');
case path.startsWith('/back1/api2'):
return path.replace('/back1/api2', '/api2');
case path.startsWith('/back2/api'):
return path.replace('/back2/api', '/api');
case path.startsWith('/back2/api2'):
return path.replace('/back2/api2', '/api2');
default:
return path;
}
};
const PROXY_CONFIG = [
{
context: [
"/auth/realms"
],
'target': 'https://keycloak-ngx1.1d35.starter-us-east-1.openshiftapps.com',
'secure': false,
'logLevel': 'debug',
// 'changeOrigin': true,
},
{
context: [
"/get"
],
'target': 'https://httpbin.org',
'secure': false,
'logLevel': 'debug',
'changeOrigin': true,
},
{
context: [
"/api"
],
'target': 'http://localhost:3000',
'secure': false
},
{
context: [
"/back1/api",
"/back1/api2",
],
'target': 'https://prod-back1-api.sumo.com:3001',
'secure': false,
'logLevel': 'debug',
"pathRewrite": rewriteFn,
'onProxyReq': function (proxyReq, req, res) {
proxyReq.setHeader('Authorization', 'Bearer ' + 'my_backend1_api_key');
},
'changeOrigin': true,
},
{
context: [
"/back2/api",
"/back2/api2",
],
'target': 'https://prod-back2-api.sumo.com:3002',
'secure': false,
'logLevel': 'debug',
"pathRewrite": rewriteFn,
'onProxyReq': function (proxyReq, req, res) {
proxyReq.setHeader('Authorization', 'Bearer ' + 'my_backend2_api_key');
},
'changeOrigin': true,
}
];
module.exports = PROXY_CONFIG;