Angular 2/ExpressJS - Refused to get unsafe header “Accept-Ranges”
See original GitHub issueUsing a webapp with NodeJS and ExpressJS as a server (CORS not configured) and Angular 2 for the client. I read here and there that I should enable CORS… I’m not sure where I should enable it and why should I enable CORS. The server is running in localhost.
Configuration:
- Web browser and its version: Chrome 53.0.2785.143
- Operating system and its version: Windows 10
- PDF.js version: 1.5.118 and 1.6.210
- Is an extension: -
Steps to reproduce the problem:
- Make a local server with NodeJS and ExpressJS
- Make an Angular 2 app
- Use an html input to upload any pdf
- Read the pdf with FileReader (with .readAsDataURL)
- Try to open the pdf with pdf.js as follow:
PDFJS.disableWorker = true;
PDFJS.getDocument(reader.result).then(function getPdf(pdf) {
pdf.getPage(1).then(function getPage(page) {
})
})
What is the expected behavior? (add screenshot) Not getting an error…
What went wrong? (add screenshot) Getting the following error:
pdf.worker.js:43268 - Refused to get unsafe header "Accept-Ranges"
Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension):
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Refused to get unsafe header "Accept-Ranges" error from pdf ...
You need to set. Access-Control-Allow-Headers : Accept-Ranges ... JS: Render PDF using an ArrayBuffer or Blob instead of URL.
Read more >Access-Control-Allow-Headers - HTTP - MDN Web Docs
The Access-Control-Allow-Headers response header is used in response to a ... Accept-Post · Accept-Ranges · Access-Control-Allow-Credentials ...
Read more >OWASP Secure Headers Project
OWASP Secure Headers Project on the main website for The OWASP Foundation. ... ma=2592000; v="46,43" accept-ranges: none vary: Accept-Encoding ...
Read more >Windows Analysis Report Past DUE statement.xlsx
Source: angular.js.2.dr, String found in binary or memory: http://angularjs. ... Source: material_css_min.css.2.dr, angular.js.2.dr ... Accept-Ranges: bytes
Read more >WhatsNew 2.0 | Ktor Framework
Ktor 2.0.3 fails with "IOException: Client provided less bytes than content ... HttpClient - -> Accept-Ranges: none 11:33:50.536 [main] INFO ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any example on how to convert from a URL to an Uint8Array if this is even possible?
@natcohen did you found a solution for the problem?
@yurydelendik i have implemented extra check for http protocol and it works fine for a simple webapp on my local machine. Please find the PR linked below and point me out if i made some mistake.
https://github.com/mozilla/pdf.js/pull/7803