Skip to content

Commit 1837331

Browse files
fix(casper): fetch uri response by sending User-Agent header if reqeust error
1 parent 71be9a5 commit 1837331

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/factory/casper.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ export const casperParser = async (
1616
default: {
1717
let uri = nft.uri;
1818
if (uri) {
19-
const res = (await axios(nft.uri));
19+
let res;
20+
try {
21+
res = await axios(nft.uri);
22+
} catch (error) {
23+
res = await axios.get(nft.uri, {
24+
headers: {
25+
"User-Agent":
26+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
27+
},
28+
});
29+
}
2030
const contentType = res.headers["content-type"];
2131
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = "1";
2232

0 commit comments

Comments
 (0)