blob: 41c8297797d387afe0ed8b7f6dd47ad67b89e10d [file] [log] [blame]
Matteo Scandoloe19fa102017-03-09 15:38:59 -08001const httpProxy = require('http-proxy');
2
Matteo Scandoload8df672017-03-29 22:34:38 -07003const target = process.env.PROXY || '192.168.46.100';
4
Matteo Scandoloe19fa102017-03-09 15:38:59 -08005const apiProxy = httpProxy.createProxyServer({
Matteo Scandoload8df672017-03-29 22:34:38 -07006 target: `http://${target}`
Matteo Scandoloe19fa102017-03-09 15:38:59 -08007});
8
Matteo Scandoloe19fa102017-03-09 15:38:59 -08009apiProxy.on('error', (error, req, res) => {
10 res.writeHead(500, {
11 'Content-Type': 'text/plain'
12 });
13 console.error('[Proxy]', error);
14});
15
Matteo Scandoloe19fa102017-03-09 15:38:59 -080016module.exports = {
17 api: apiProxy,
Matteo Scandoloe19fa102017-03-09 15:38:59 -080018};