Skip to content

Commit

Permalink
Forward upstream reputation errors correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
area committed Aug 6, 2024
1 parent 76861a5 commit af57ad2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/reputation-miner/bin/forked.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,19 @@ async function main() {
const { data } = await axios.get(`http://localhost:${3001}/${req.originalUrl}`);
res.send(data);
} catch (e) {
console.log('Local reputation request failed, try upstream URL:');
console.log('Local reputation request failed, trying upstream URL:');
// If the local oracle fails, query the upstream oracle.
console.log(`${process.env.REPUTATION_URL}/${req.originalUrl}`)
try {

const { data } = await axios({
url: `${process.env.REPUTATION_URL}/${req.originalUrl}`,
responseType: "stream",
});

res.send(data);
} catch (e2) {
console.log('Upstream reputation request failed');
res.status(500).send(e2);
console.log('Upstream reputation request failed, forwarding result');
res.status(e2.response.status).send(await e2.response.data);
}
}
});
Expand Down

0 comments on commit af57ad2

Please sign in to comment.