ngx-extended-pdf-viewer not working with Url

Viewed 5428

I cannot get my pdf to display on viewer via url in typescript. I am using ngx-extended-pdf-viewer

Here is an example of my code with the URL replaced.

<ngx-extended-pdf-viewer 
*ngIf="!isFirefox"  
  [src]="'http://www.childrensbooksforever.com/Childrenpics/A%20COOL%20KID%20LIKE%20ME.pdf'"
  useBrowserLocale="true" 
  backgroundColor="#000000" 
  height="100%">            
</ngx-extended-pdf-viewer>

Error message in the viewer:

PDF.js v2.1.266 (build: 81f5835c)
Message: Failed to fetch

in the pdf viewer.

I can view the pdf if i place it in the assets folder but the url doesn't work. An empty frame is shown. What am I doing incorrectly?

1 Answers

I can only guess, but my most likely explanation is "CORS". Modern browsers protect you against a certain class of hacker attacks by refusing to download or send stuff from another URL.

You've mentioned accessing local file works, so chances are using a proxy will fix the problem. For example, there's the proxy-conf.json in the Angular CLI.

Related