blob: a0d9ee02a08a9fc1dd5df53cc2950616286eaf99 [file] [log] [blame]
Matteo Scandoloc46a82d2017-03-24 18:37:18 -07001const httpProxy = require('http-proxy');
2
3const target = process.env.PROXY || '192.168.46.100';
4
5const apiProxy = httpProxy.createProxyServer({
6 target: `http://${target}:9101`
7});
8
9const staticFilesProxy = httpProxy.createProxyServer({
10 target: `http://${target}/spa`
11});
12
13apiProxy.on('error', (error, req, res) => {
14 res.writeHead(500, {
15 'Content-Type': 'text/plain'
16 });
17 console.error('[Proxy]', error);
18});
19
20staticFilesProxy.on('error', (error, req, res) => {
21 res.writeHead(500, {
22 'Content-Type': 'text/plain'
23 });
24 console.error('[Proxy]', error);
25});
26
27module.exports = {
28 api: apiProxy,
29 static: staticFilesProxy
30};