Frameworks
Integrations
Mendix
SharePoint
Default UI
Modular UI
AnnotationManager
Annotation Types
Customize
Version 11
Version 10
v10.12
v10.11
v10.10
v10.9
v10.8
v10.7
v10.6
v10.5
v10.4
v10.3
v10.2
v10.1
v10.0
Version 8
v8.12
v8.11
v8.10
v8.9
v8.8
v8.7
v8.6
v8.5
v8.4
v8.3
v8.2
v8.1
v8.0
Version 7
Version 6
v6.3
v6.2
v6.1
v6.0
Version 5
Version 4
Version 3
Version 2
WebViewer Server
WebViewer BIM
In some situations you may want to place the large WebViewer worker files on a CDN or some other external server. It's possible to put the entire WebViewer lib
folder on another domain however this has some downsides, so only moving the core files is often a good compromise.
We provide a few APIs to help accomplish this, setWorkerPath
and setLocalWorkerPath
.
The first step is to copy the core files and their resources to your external server. Once you download WebViewer, find the following folder:
lib/core
This is the only folder you need to copy to your CDN or other external server.
Now you need to tell WebViewer where the workers live. To do this, pass an accessible, absolute path to your folder into the setWorkerPath
function.
Add the following code to the top of your config file.
Make sure the path you pass in contains all the worker folders, and that they are publicly accessible.
In order for us to load these workers from an external domain, we need to use local workers that load the external workers. This is because remote workers cannot be directly loaded from the browser because of security restrictions.
WebViewer needs to know where these local workers exist, and we can use the setLocalWorkerPath
API to help it find them.
The path that you pass to setLocalWorkerPath
must be on the same domain as your app, and is relative to the index file of the UI, which is usually lib/ui/index.html
. The path must point to the folder that contains CORSWorker.js
and Worker.js
, which in most cases is lib/core
.
Add the following code underneath the code you added above (in your config file).
That's it! Your worker files will now be loaded from your CDN or external server.
WebViewer WebComponent does not utilize config files and setting up remote workers is almost the same with slight differences. You can call setLocalWorkerPath
and setWorkerPath
APIs directly after the WebComponent promise resolves.
Follow the step one and step two as shown above to setup remote worker. You can also copy UI resource files if you would like.
Make sure you also place the CORSWorker.js
and Worker.js
files on the same domain as your app as shown in step two.
Additionally, if you're enabling content edit feature of the WebViewer you also need to set the path for the content edit workers using Core.ContentEdit.setResourcePath
and Core.ContentEdit.setWorkerPath
.
If you receive cross origin errors accessing the worker files on the other domain then make sure that you have the Access-Control-Allow-Origin
header on these resources, otherwise they won't be able to be loaded from the other domain.
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales