drewzboto / grunt-connect-proxy

Grunt Connect support for proxying API calls during development
MIT License
423 stars 122 forks source link

handle error on request #124

Open abuscom-leonhard opened 9 years ago

abuscom-leonhard commented 9 years ago

The actual version does not handle errors well. They are being lost with a simple error message Proxy error: .... I would suggest to add the following lines to the error handling in the createProxyServer Section

utils.registerProxy({
              server: httpProxy.createProxyServer({
                target: proxyOption,
                secure: proxyOption.https,
                xfwd: proxyOption.xforward
              }).on('error', function (err, req, res) {
                grunt.log.error('Proxy error: ', err.code);
                res.writeHead(500, {
                      'Content-Type': 'text/plain'
                });
                res.end('Something went wrong.' + err.code);
              }),