Skip to content

Commit

Permalink
feat: add extra fallback for auth token
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterNjeim committed Jun 7, 2024
1 parent 2d67284 commit 647c1aa
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,25 @@ export const getFileUrl = async (
});

if (!r.ok) {
auth = await getApiAuthNetwork(type, index);
if (type === "img" && index === 0) {
// auth is the URL for the first page
r = await _fetch(auth);
} else {
r = await _fetch(url, {
headers: {
Authorization: auth,
},
});
auth = md5(`${id}${type}${index}01000`).slice(0, 4);
r = await _fetch(url, {
headers: {
Authorization: auth,
},
});

if (!r.ok) {
auth = await getApiAuthNetwork(type, index);
if (type === "img" && index === 0) {
// auth is the URL for the first page
r = await _fetch(auth);
} else {
r = await _fetch(url, {
headers: {
Authorization: auth,
},
});
}
}
}

Expand Down

0 comments on commit 647c1aa

Please sign in to comment.