Failure to load seemingly valid AWS S3 Signed URL

Using PDF.js Express Viewer version 8.4.1 (UI) 8.4.0 (Core)

I am having a difficult time determining why this particular signed AWS URL will not work in the Express Viewer. It just gives me a “Failed to fetch” error message. If I paste this URL in a browser tab it correctly downloads the PDF file. This is an harmless test file with a 7 day link expiration so hopefully if you can review it before it expires that’d be great. Or if there’s a ‘verbose’ debug flag or something I can flip on in the viewer to get more info that’d be great too. Thanks!

https://portal-dev-email-attachments.s3.us-east-1.amazonaws.com/4aaa055f-dca5-42e5-ae0f-790212ebe98e?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA5PYGN7M6TGLRTOVD%2F20220622%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220622T141306Z&X-Amz-Expires=604800&X-Amz-Signature=bb851ce1fdd33fd28e4cce96b754886470a199dad33f0a489d22c448d0e381aa&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%20%3D%22pdf-lib_pdf_page_embedding_example%2520%281%29.pdf%22&x-id=GetObject

Hi Steve,

Taking a look at the error messages on my end, I suspect this to be a CORS issues with the server where this PDF is hosted.

How are you loading that PDF link into express?

What are your CORS settings on that hosted server?

Here is a guide on troubleshooting CORS support in WebViewer but should be the same process for PDF.js Express

Best Regards,
Zach Serviss
Web Development Support Engineer
PDFTron Systems, Inc.
www.pdftron.com

I have successfully loaded a PDF from another S3 bucket of ours. I do see CORS errors on the HEAD but it still loads eventually. That behavior seemed to be related to this ticket 1657 (pdf-js-express-access-to-aws-s3-object-with-pre-signed-url) - can’t paste the link.

We’re using AWS Serverless so I’ll have to check on any CORS settings.

Discovered that not all of our S3 buckets have the same CORS configuration on them. Updated this particular bucket and it is working now. Thanks for the suggestion.