Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in AWS by (19.1k points)

I'm trying to use pdf.js with range requests (progressive loading of the pdf document), but when I'm trying to load the pdf from amazon s3 urls this error appears in the console :

-Refused to get unsafe header "Accept-Ranges"

and the pdf doesn't load via 206 partial content (range requests) but 200 and then viewed in the viewer.

1 Answer

0 votes
by (44.3k points)

Set your Amazon CORS policy like this:

<?xml version="1.0" encoding="UTF-8"?>

<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">

    <CORSRule>

        <AllowedOrigin>*</AllowedOrigin>

        <AllowedMethod>GET</AllowedMethod>

        <AllowedMethod>PUT</AllowedMethod>

        <AllowedMethod>POST</AllowedMethod>

        <AllowedMethod>DELETE</AllowedMethod>

        <MaxAgeSeconds>3000</MaxAgeSeconds>

        <!-- this part is critical -->

        <AllowedHeader>*</AllowedHeader>

        <ExposeHeader>Accept-Ranges</ExposeHeader>

        <ExposeHeader>Content-Encoding</ExposeHeader>

        <ExposeHeader>Content-Length </ExposeHeader>

        <ExposeHeader>Content-Range</ExposeHeader>

     </CORSRule>

</CORSConfiguration>

This might help.

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer
+1 vote
1 answer
asked Oct 31, 2019 in Data Science by chandra (29.3k points)
0 votes
1 answer
asked Aug 14, 2019 in Web Technology by Sammy (47.6k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...