Skip to main content
CESDK/CE.SDK/Editor/Guides

Configure the SDK to Use Assets Served From Your Own Servers

Learn how to serve assets from your own servers in the CreativeEditor SDK.

In this example, we explain how to configure the CE.SDK to use assets hosted on your own servers. While we serve all assets from our own CDN by default, it is highly recommended to serve the assets from your own servers in a production environment.

Prerequisites#

1. Add the CE.SDK to Your Project#

npm install --save @cesdk/cesdk-js@1.9.0

2. Copy Assets#

Copy the CE.SDK asset folder to your application's asset folder. The name of the folder depends on your setup and the used bundler, but it's typically a folder called assets or public in the project root.

cp -r ./node_modules/@cesdk/cesdk-js/assets public/

If you deploy the site that embeds the CE.SDK together with all its assets and static files, this might be all you need to do for this step.

In different setups, you might need to upload this folder to your CDN.

3. Configure the CE.SDK to use your self-hosted assets#

Next, we need to configure the SDK to use our local assets instead of the ones served via our CDN. There are two configuration options that are relevant for this:

  • baseURL points to the assets folder that was copied in the previous step.

    This can be either an absolute URL, or a path. A path will be resolved using the window.location.href of the page where the CE.SDK is embedded. By default baseURL is set to our CDN.

  • core.baseURL points to the folder containing the webassembly sources and data file for the CE.SDK.

    This can be either an absolute URL, or a relative path. A relative path will be resolved using the the previous baseURL. By default, core.baseURL is set to core/.

    Normally you would simply serve the assets directory from the previous step. That directory already contains the core folder, and this setting does not need to be changed. For highly customized setups that separate hosting of the WASM files from the hosting of other assets that are used inside scenes, you can set this to a different URL.

const config = {
...
baseURL: '/assets' // or 'https://cdn.mydomain.com/assets'
core: {
baseURL: 'core/
},
...
};

Versioning of the WASM assets#

The .wasm and .data files that the CE.SDK loads from core.baseURL are changing between different versions of the CE.SDK. You need to ensure that after a version update, you update your copy of the assets.

The filenames of these assets will also change between updates. This makes it safe to store different versions of these files in the same folder during migrations, as the CE.SDK will always locate the correct files using the unique filenames.

It also means that if you forget to copy the new assets, the CE.SDK will fail to load them during initialization and abort with an Error message on the console. Depending on your setup this might only happen in your production or staging environments, but not during development where the assets might be served from a local server. Thus we recommend to ensure that copying of the assets is taken care of by your automated deployments and not performed manually.