stephanrauh / ngx-extended-pdf-viewer

A full-blown PDF viewer for Angular 16, 17, and beyond
https://pdfviewer.net
Apache License 2.0
449 stars 167 forks source link

ngx-extended-pdf-viewer giving 404 not found error. #2369

Closed Jammy1299 closed 1 day ago

Jammy1299 commented 1 week ago

I have updated my ngx-extended-pdf-viewer to version 19.4.1 and my angular application to version 16.

The ngx-extended-pdf-viewer is working fine in local. But when I am deploying this to environment I am getting this error.

pdf issue

And In network tab I can see this

pdfissue2

image

extra assets label in adding in the URL.

I am using chrome browser.

stephanrauh commented 1 week ago

Yes, there's an extra assets/ in the URL when the viewer tries to load the worker into the main thread. But it should never reach that line. So let's focus on the first attempt to load it. Your screenshot says the file is blocked. Blocked by what?

BTW, a workaround is to load the pdf.worker*.mjs yourself. For instance, you can add a <script> tag to the index.html. However, that's not a good solution because it costs performance and because the version number of the file changes with every release.

Jammy1299 commented 1 week ago

I have downgraded to version 18.1.14 and now Its working with my angular version 16. Can we make it to work with version 19 or 20? Also why this issue only coming in production but not in local.

agrube commented 1 week ago

Are you encountering an error that looks something like this?

image

If so, you're having a CORS issue on your production server that is blocking the worker file. Make sure your worker-src is defined and specifies 'self' so it doesn't attempt to fall back onto the child-src.

stephanrauh commented 1 week ago

@Jammy1299 The issue happens in only production because you're using a different server in production. Usually, you also have a firewall and other security measures in production. When you say it works again after downgrading, you'll want to check whether your server has a problem with *.mjs files. On the other hand, that's unlikely because the other JavaScript files are loaded correctly.

stephanrauh commented 1 day ago

Did you manage to solve the issue?