diff --git a/karma.conf.js b/karma.conf.js index 4c574b7..07b4135 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -8,7 +8,7 @@ module.exports = function (config) { singleRun: true, frameworks: [ 'mocha' ], - + files: [ 'tests.webpack.js' ], diff --git a/src/server.js b/src/server.js index 7c63a3f..37575c6 100755 --- a/src/server.js +++ b/src/server.js @@ -29,6 +29,18 @@ app.use('/api', (req, res) => { proxy.web(req, res); }); +// added the error handling to avoid https://github.com/nodejitsu/node-http-proxy/issues/527 +proxy.on('error', (error, req, res) => { + let json; + console.log('proxy error', error); + if (!res.headersSent) { + res.writeHead(500, {'content-type': 'application/json'}); + } + + json = { error: 'proxy_error', reason: error.message }; + res.end(JSON.stringify(json)); +}); + app.use((req, res) => { if (__DEVELOPMENT__) { // Do not cache webpack stats: the script file would change since