Skip to content

Commit b9716e4

Browse files
committed
Handle AWS S3 hosted books
When a book has an AWS S3 presigned URL setting the authentication header causes the download to fail.
1 parent fbb287c commit b9716e4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/lib/DownloadClient.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,15 @@ export default class DownloadCLient {
6868
authToken: string
6969
): Promise<ArrayBuffer> {
7070
try {
71-
const response = await fetch(url, {
72-
headers: APIHandler.getHeaders(authToken),
73-
});
71+
var opts = {};
72+
const parsedUrl = new URL(url);
73+
if (parsedUrl.hostname.endsWith("libro.fm")) {
74+
opts = {
75+
headers: APIHandler.getHeaders(authToken),
76+
};
77+
}
78+
79+
const response = await fetch(url, opts);
7480
const buffer = await response.arrayBuffer();
7581

7682
return buffer;

0 commit comments

Comments
 (0)