blob: d2459d8dba1d1efdc34d729ac79ad8cbfdaa343d [file] [log] [blame]
Matteo Scandoloc80ccbd2017-02-27 16:24:33 -08001const httpProxy = require('http-proxy');
2
Matteo Scandolo47c53fc2017-03-23 14:11:32 -07003const target = process.env.PROXY || '192.168.46.100';
4
Matteo Scandoloc80ccbd2017-02-27 16:24:33 -08005const proxy = httpProxy.createProxyServer({
Matteo Scandolo47c53fc2017-03-23 14:11:32 -07006 target: `http://${target}:9101`
Matteo Scandoloc80ccbd2017-02-27 16:24:33 -08007});
8
Matteo Scandolo98b5f5d2017-03-17 17:09:05 -07009const extensionsProxy = httpProxy.createProxyServer({
Matteo Scandolo47c53fc2017-03-23 14:11:32 -070010 target: `http://${target}/spa/`
Matteo Scandolo98b5f5d2017-03-17 17:09:05 -070011});
12
Matteo Scandoloc80ccbd2017-02-27 16:24:33 -080013proxy.on('error', function(error, req, res) {
14 res.writeHead(500, {
15 'Content-Type': 'text/plain'
16 });
17 console.error('[Proxy]', error);
18});
19
Matteo Scandolo98b5f5d2017-03-17 17:09:05 -070020module.exports = {
21 proxy,
22 extensionsProxy
23};