PDF Viewer -- CORS error

0 Answers 88 Views
PDF Viewer
Janki
Top achievements
Rank 4
Bronze
Iron
Iron
Janki asked on 15 Jul 2024, 08:26 PM

Hey there,

I'm trying to use the PDFViewer component, but it's always returning a CORS error for me. I know it's not a real CORS error because if I swap out the PDFViewer component with an <embed>, it displays the file correctly. What can I do to resolve this issue?

Janki
Top achievements
Rank 4
Bronze
Iron
Iron
commented on 15 Jul 2024, 08:33 PM

Chrome Embed Request Headers


Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7

Accept-Encoding:gzip, deflate, br, zstd

Accept-Language:en-US,en;q=0.9

Cache-Control:no-cache

Pragma:no-cache

Priority:u=0, i

Referer:https://localhost:44375/

Sec-Ch-Ua:"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"

Sec-Ch-Ua-Mobile:?0

Sec-Ch-Ua-Platform:"Windows"

Sec-Fetch-Dest:embed

Sec-Fetch-Mode:navigate

Sec-Fetch-Site:cross-site

Upgrade-Insecure-Requests:1

User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36




Kendo PDF Viewer Request Headers


Accept:*/*

Accept-Encoding:gzip, deflate, br, zstd

Accept-Language:en-US,en;q=0.9

Origin:https://localhost:44375

Priority:u=1, i

Referer:https://localhost:44375/
Sec-Ch-Ua:"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"

Sec-Ch-Ua-Mobile:?0

Sec-Ch-Ua-Platform:"Windows"

Sec-Fetch-Dest:empty

Sec-Fetch-Mode:cors

Sec-Fetch-Site:cross-site

User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Janki
Top achievements
Rank 4
Bronze
Iron
Iron
commented on 15 Jul 2024, 08:35 PM | edited

This is what seems to differ mainly between the two:

Sec-Fetch-Dest:embed for <embed> vs empty for <PDFViewer>

Sec-Fetch-Mode:navigate for <embed> vs cors for <PDFViewer>

Filip
Telerik team
commented on 17 Jul 2024, 01:20 PM

Hello, Janki,

I inspected the provided requests and it seems that the issue is due to a configuration on the server side, however, without an example, it will be hard to tell for sure. I can recommend enabling CORS (in case you haven't already) or proxying the request through your server. This way, the server will make the request to the PDF and serve it to your client, bypassing the CORS restrictions.

In case the issue persists, can you please send me a runnable example that reproduces the issue? This will enable me to debug it locally and find the root cause of the CORS error

Regards,
Filip

No answers yet. Maybe you can help?

Tags
PDF Viewer
Asked by
Janki
Top achievements
Rank 4
Bronze
Iron
Iron
Share this question
or