Getting the 'File preview error'.
Here's my code:
The URL to the file works fine.
What am I doing wrong? Thanks!
Do you see any CORS error in the browser console?
This is the information available in the PDF Embed API documentation:
Cross-origin resource sharing (CORS) issues may occur when you pass PDF content as a URL and the PDF Embed API needs to download the file from the provided location in order to render it. To avoid this situation, you can choose one of two methods:
Enable CORS headers on the PDF resource to allow access from your webpage domain.
Please see if this fixes the issue.
These are the errors:
These errors can be ignored for now. These won't impact the functionality.
Could you please check that it's not due to CORS? Thanks!
After trying all possible hits and trials, I found a solution that worked for me.
Below is the code I was trying and was getting the same File Preview Error. As you can see, the url starts with http and ends with the file name.
I just removed the http://syncit.in and gave the rest of the path for the file name like below, and it worked for me:
Hope this helps solve the issue.