Error loading PDF viewer different domain

I am loading the viewer from public dir in S3 same bucket that my site is getting served from, this is a react app, the bundle is in the assets dir.

Index.html lives inside this bucket at the same level as the public folder, Below is my code to initialize the WebVier, not sure what I’m doing wrong at this stage.

WebViewer(
            {
                path: '/public',
                initialDoc: ''
            },

Screen Shot 2021-09-09 at 2.22.37 pm

This is the ERROR I am getting in the console:

Refused to display ‘https://#######/’ in a frame because it set ‘X-Frame-Options’ to ‘deny’.

Error loading PDF viewer Viewer is on a different domain, the promise from WebViewer function is rejected and API functions will not work because of cross domain permissions. See https://www.pdftron.com/kb_cross_origin for more information.

Hello Laza,

Reading this error, it sounds like a CORS issue, we have a guide on setting up CORS for S3 here:

We also have a React sample here, there is a script in there that copies WebViewer files to a public directory, which is similar to how you are setting up:

Best Regards,

Tyler Gordon
Web Development Support Engineer
PDFTron Systems, Inc.
www.pdftron.com