Skip to content

Commit

Permalink
Merge pull request #3 from atrifat/fix-proper-response
Browse files Browse the repository at this point in the history
Fix proper response
  • Loading branch information
atrifat authored Sep 21, 2023
2 parents b887f63 + fe2b591 commit 04d7517
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 157 deletions.
158 changes: 3 additions & 155 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ const loadBalancerHandler = async (req, res) => {
if (ENABLE_CACHE) responseCache.set(req_key, response.data);

// Send back the response data from application server to client
res.send(response.data);
res.status(response.status).header(response.headers).send(response.data);
}
catch (err) {
// Send back the error message
// console.error(err);
console.error(err);
const statusCode = err.response ? err.response.status : 500;
const message = err.response ? typeof err.response.data.message ? err.response.data.message : err.response.reason.message || err.response.code || err.message || "Server error!" : "Server error!";
res.status(statusCode).send(message);
Expand Down

0 comments on commit 04d7517

Please sign in to comment.