Matteo Scandolo | e19fa10 | 2017-03-09 15:38:59 -0800 | [diff] [blame] | 1 | const httpProxy = require('http-proxy'); |
| 2 | |
| 3 | const apiProxy = httpProxy.createProxyServer({ |
| 4 | target: 'http://192.168.46.100:9101' |
| 5 | }); |
| 6 | |
| 7 | const staticFilesProxy = httpProxy.createProxyServer({ |
| 8 | target: 'http://192.168.46.100/spa' |
| 9 | }); |
| 10 | |
| 11 | apiProxy.on('error', (error, req, res) => { |
| 12 | res.writeHead(500, { |
| 13 | 'Content-Type': 'text/plain' |
| 14 | }); |
| 15 | console.error('[Proxy]', error); |
| 16 | }); |
| 17 | |
| 18 | staticFilesProxy.on('error', (error, req, res) => { |
| 19 | res.writeHead(500, { |
| 20 | 'Content-Type': 'text/plain' |
| 21 | }); |
| 22 | console.error('[Proxy]', error); |
| 23 | }); |
| 24 | |
| 25 | module.exports = { |
| 26 | api: apiProxy, |
| 27 | static: staticFilesProxy |
| 28 | }; |