Skip to content

Commit

Permalink
Merge pull request #100 from thiagobustamante/master
Browse files Browse the repository at this point in the history
 Fix Can\'t set headers after they are sent.
  • Loading branch information
thiagobustamante committed Jan 25, 2018
2 parents 504f11c + 5574778 commit af9a797
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tree-gateway",
"version": "1.5.6",
"version": "1.5.7",
"homepage": "http://treegateway.org",
"description": "The Tree Gateway API Gateway",
"author": "Thiago da Rosa de Bustamante <trbustamante@gmail.com>",
Expand Down
4 changes: 3 additions & 1 deletion src/proxy/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ export class ApiProxy {
const errReference = 'https://nodejs.org/api/errors.html#errors_common_system_errors'; // link to Node Common Systems Errors page

this.logger.error('[Tree-Gateway] Error occurred while trying to proxy request %s from %s to %s (%s) (%s)', req.url, hostname, target, err.code, errReference);
res.status(502).send('Bad Gateway');
if (!res.headersSent) {
res.status(502).send('Bad Gateway');
}
});

const maybeWrapResponse = this.interceptor.hasResponseInterceptor(api.proxy);
Expand Down

0 comments on commit af9a797

Please sign in to comment.