Skip to content

Commit

Permalink
Handle AWS S3 hosted books
Browse files Browse the repository at this point in the history
When a book has an AWS S3 presigned URL setting the authentication header
causes the download to fail.
  • Loading branch information
guildencrantz committed May 13, 2024
1 parent fbb287c commit b9716e4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/lib/DownloadClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ export default class DownloadCLient {
authToken: string
): Promise<ArrayBuffer> {
try {
const response = await fetch(url, {
headers: APIHandler.getHeaders(authToken),
});
var opts = {};
const parsedUrl = new URL(url);
if (parsedUrl.hostname.endsWith("libro.fm")) {
opts = {
headers: APIHandler.getHeaders(authToken),
};
}

const response = await fetch(url, opts);
const buffer = await response.arrayBuffer();

return buffer;
Expand Down

0 comments on commit b9716e4

Please sign in to comment.