generated from B3Partners/tailormap-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy.config.js
22 lines (20 loc) · 877 Bytes
/
proxy.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const useLocalhost = process.env.PROXY_USE_LOCALHOST === 'true';
module.exports = {
"/api":{
"target": useLocalhost ? "http://127.0.0.1:8080" : "https://snapshot.tailormap.nl",
"secure": false,
"logLevel": "info",
"headers": useLocalhost ? {} : {
// Send HTTP Host request header for name-based virtual host
"Host": "snapshot.tailormap.nl"
},
onProxyRes(proxyRes, req) {
const host = req.headers.host;
if(proxyRes.headers['location']) {
// Rewrite the Location response header for redirects on login/logout (like the Apache ProxyPassReverse directive)
const hostDestination = host.indexOf('localhost:4201') ? 'http://localhost:4201' : 'http://localhost:4200';
proxyRes.headers['location'] = proxyRes.headers['location'].replace('https://snapshot.tailormap.nl', hostDestination);
}
},
}
};