-
Notifications
You must be signed in to change notification settings - Fork 26
/
backend-proxy-remote.conf.js
45 lines (42 loc) · 1.42 KB
/
backend-proxy-remote.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
let backendhostname = process.env.RUNBOX7_ANGULAR_BACKEND_HOST;
let backendhostsecure = true;
if(backendhostname)
{
// If we're using a custom (development) backend, turn off security checking to avoid certificate errors:
backendhostsecure = false;
}
else
{
// Default to production backend
backendhostname = 'https://runbox.com';
}
const PROXY_CONFIG = [
{
context: ["/websocket"],
"target": backendhostname.replace(/^http/,'ws'),
"secure": backendhostsecure,
"ws": true,
"changeOrigin": true
},
{
context: [
"/rest", "/LOGOUT", "/mail", "/ajax", "/_js", "/_img", "/_css", "/_ics", "/app", "/angular2", "/locale", "/signup", "pw_reset"
],
onProxyRes: (proxyRes, req, res) => {
if (proxyRes.headers['set-cookie']) {
const cookies = proxyRes.headers['set-cookie'].map(cookie =>
cookie.replace(/; secure/gi, '')
);
proxyRes.headers['set-cookie'] = cookies;
}
if(proxyRes.headers['location']) {
proxyRes.headers['location'] = proxyRes.headers['location'].replace(backendhostname, '');
}
},
"target": backendhostname,
"secure": backendhostsecure,
"cookieDomainRewrite": "localhost",
"changeOrigin": true
}
]
module.exports = PROXY_CONFIG;