blob: d45a27ba8dde1edb56e5d73ae61d47da0637d503 [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 Scandoloe015fa92017-05-10 09:52:36 -07006 target: `http://${target}`
Matteo Scandoloc80ccbd2017-02-27 16:24:33 -08007});
8
Matteo Scandolo98b5f5d2017-03-17 17:09:05 -07009const extensionsProxy = httpProxy.createProxyServer({
Matteo Scandolo37d56062017-04-24 15:03:00 -070010 target: `http://${target}/xos/`
Matteo Scandolo98b5f5d2017-03-17 17:09:05 -070011});
12
Matteo Scandoloe015fa92017-05-10 09:52:36 -070013const socketProxy = httpProxy.createProxyServer({
14 target: `http://${target}/`
15});
16
Matteo Scandoloc80ccbd2017-02-27 16:24:33 -080017proxy.on('error', function(error, req, res) {
Matteo Scandoloe015fa92017-05-10 09:52:36 -070018 res.writeHead(500, {'Content-Type': 'text/plain'});
Matteo Scandoloc80ccbd2017-02-27 16:24:33 -080019 console.error('[Proxy]', error);
20});
21
Matteo Scandoloe015fa92017-05-10 09:52:36 -070022extensionsProxy.on('error', function(error, req, res) {
23 res.writeHead(500, {'Content-Type': 'text/plain'});
24 console.error('[extensionsProxy]', error);
25});
26
27socketProxy.on('error', function(error, req, res) {
28 res.writeHead(500, {'Content-Type': 'text/plain'});
29 console.error('[socketProxy]', error);
30});
31
Matteo Scandolo98b5f5d2017-03-17 17:09:05 -070032module.exports = {
33 proxy,
Matteo Scandoloe015fa92017-05-10 09:52:36 -070034 extensionsProxy,
35 socketProxy
Matteo Scandolo98b5f5d2017-03-17 17:09:05 -070036};