0

Trying to use viwerjs (https://viewerjs.org/) . My directory structure is given bellow.

Main
  ViwerJS
  mydoc.pdf
  main.html

My browser shows CORS error . Here is my code

<iframe src="ViewerJS/index.html#../mydoc.pdf" width="100%" ></iframe>

It shows Access to XMLHttpRequest at from origin 'null' has been blocked by CORS policy How can I fix that

kashfiq
  • 43
  • 1
  • 7
  • Does this answer your question? [Why does my JavaScript code receive a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error, while Postman does not?](https://stackoverflow.com/questions/20035101/why-does-my-javascript-code-receive-a-no-access-control-allow-origin-header-i) – machineghost May 22 '21 at 16:04
  • not really . Can you please specify the solution – kashfiq May 22 '21 at 16:08
  • It's describing the exact same problem ... and how to fix it. You are trying to make a request to a different domain than the one making the request (eg. you are on `a.com`, and your PDF is on `b.com`). Browsers block that, as a safety feature ... unless your server uses CORS headers (described in that question's answers). – machineghost May 22 '21 at 16:12
  • P.S. If you are just having technical trouble with a tool (VIewerJS) and aren't trying to understand the underlying issue, you are in the wrong place. Stack Overflow isn't for "bug help" with tools: you should use the "Issues" section of tool's GitHub page for that: https://github.com/webodf/ViewerJS/issues/. This issue in particular might be relevant: https://github.com/webodf/ViewerJS/issues/288 – machineghost May 22 '21 at 16:17

0 Answers0