Skip to content

Commit

Permalink
fix(casper): fetch uri response by sending User-Agent header if reqeu…
Browse files Browse the repository at this point in the history
…st error
  • Loading branch information
muhammadusmanuet committed Dec 2, 2024
1 parent 71be9a5 commit 1837331
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/factory/casper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ export const casperParser = async (
default: {
let uri = nft.uri;
if (uri) {
const res = (await axios(nft.uri));
let res;
try {
res = await axios(nft.uri);
} catch (error) {
res = await axios.get(nft.uri, {
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
},
});
}
const contentType = res.headers["content-type"];
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = "1";

Expand Down

0 comments on commit 1837331

Please sign in to comment.