Can you reproduce using one of our samples or online demos?
Don’t know, haven’t been able to find a sample where the WebViewer lib files are served from a different domain than the main app.
Are you using the WebViewer server?
No
Does the issue only happen on certain browsers?
No
Is your issue related to a front-end framework?
No
Is your issue related to annotations?
No
Please give a brief summary of your issue:
The WebViewer lib files are served from a different subdomain than our app. We’re trying to instantiate WebViewer.WebComponent but getting the error message…
Please describe your issue and provide steps to reproduce it:
Currently, I’m just trying to imlement locally, thus the urls in the error message above containing aristotle.local.
From the error message, it looks like you are experiencing CORS issue, could you please try following our CORS guide and see if that resolves your issue?
Thanks for the response. The following was done locally. I’m getting a different exception now, but still not working. I should mention that instantiating the WebViewer the legacy way (iframe) works fine without needing to add CORS headers to the local server.
import cors from 'cors'
// Changed
app.use('/cdn', express.static('../../ui/cdn'))
// To
app.use('/cdn', cors(), express.static('../../ui/cdn'))
// This mimics are environments in AWS where are app loads from xxx.aristotle.ai and our assets (including webviewer) load from cdn.aristotle.ai
UI WebComponent instantiation
// Utils.requireFromCDN returns an absolute URL to the path/file given
// Locally, this produces http://cdn.aristotle.local:3000/cdn/1.15.9/{path}
const viewer = await WebViewer.WebComponent(
{
config: Utils.requireFromCDN('webviewer/ui/config.js'),
licenseKey: 'xxx',
isReadOnly: true,
path: Utils.requireFromCDN('webviewer'),
preloadWorker: 'pdf',
},
element
)
It looks like you are still experiencing some kind of CORS issue, could you please try following the express guide here: enable cross-origin resource sharing
Also, I see that you use the config option in your WV constructor. This method was to originally circumvent the iframe being on a different domain:
Nope, made no difference. I’m not sure CORS matters here, as it’s the browser throwing an exception when webviewer-core.min.js tries to instantiate a new worker with the following url…
For now this looks to be a known issue and is in our backlog to investigate.
We will let you know when this has been completed and you can also watch out for our changelogs