Matteo Scandolo | c80ccbd | 2017-02-27 16:24:33 -0800 | [diff] [blame] | 1 | const httpProxy = require('http-proxy'); |
| 2 | |
Matteo Scandolo | 47c53fc | 2017-03-23 14:11:32 -0700 | [diff] [blame] | 3 | const target = process.env.PROXY || '192.168.46.100'; |
| 4 | |
Matteo Scandolo | c80ccbd | 2017-02-27 16:24:33 -0800 | [diff] [blame] | 5 | const proxy = httpProxy.createProxyServer({ |
Matteo Scandolo | 47c53fc | 2017-03-23 14:11:32 -0700 | [diff] [blame] | 6 | target: `http://${target}:9101` |
Matteo Scandolo | c80ccbd | 2017-02-27 16:24:33 -0800 | [diff] [blame] | 7 | }); |
| 8 | |
Matteo Scandolo | 98b5f5d | 2017-03-17 17:09:05 -0700 | [diff] [blame] | 9 | const extensionsProxy = httpProxy.createProxyServer({ |
Matteo Scandolo | 47c53fc | 2017-03-23 14:11:32 -0700 | [diff] [blame] | 10 | target: `http://${target}/spa/` |
Matteo Scandolo | 98b5f5d | 2017-03-17 17:09:05 -0700 | [diff] [blame] | 11 | }); |
| 12 | |
Matteo Scandolo | c80ccbd | 2017-02-27 16:24:33 -0800 | [diff] [blame] | 13 | proxy.on('error', function(error, req, res) { |
| 14 | res.writeHead(500, { |
| 15 | 'Content-Type': 'text/plain' |
| 16 | }); |
| 17 | console.error('[Proxy]', error); |
| 18 | }); |
| 19 | |
Matteo Scandolo | 98b5f5d | 2017-03-17 17:09:05 -0700 | [diff] [blame] | 20 | module.exports = { |
| 21 | proxy, |
| 22 | extensionsProxy |
| 23 | }; |