Learn how to intercept and transform asset URIs in CE.SDK, enabling authentication and custom resolution logic.

When CE.SDK loads an asset, it resolves the URI to an absolute path before fetching. You can intercept this process to add authentication tokens or transform URIs based on your application’s needs.
Default URI Resolution#
By default, CE.SDK resolves URIs relative to the basePath setting. Absolute URIs (with http://, https://, data:) pass through unchanged, while relative paths get prepended with basePath.
Use getAbsoluteURI() to test how URIs resolve without loading assets:
// Test resolution without loading assetsconst relativeURI = '/images/photo.jpg';const resolvedURI = engine.editor.getAbsoluteURI(relativeURI);// eslint-disable-next-line no-consoleconsole.log('Default resolution:');// eslint-disable-next-line no-consoleconsole.log(` Input: ${relativeURI}`);// eslint-disable-next-line no-consoleconsole.log(` Output: ${resolvedURI}`);Custom URI Resolver#
Set a custom resolver to intercept and transform URIs. The resolver receives the URI and a defaultURIResolver function for fallback behavior:
// Set a custom resolver that transforms specific file typesengine.editor.setURIResolver((uri, defaultURIResolver) => { // Transform JPG files to a watermarked version if (uri.endsWith('.jpg')) { // eslint-disable-next-line no-console console.log(`Custom resolver: Transforming ${uri}`); return 'https://img.ly/static/ubq_samples/sample_1.jpg'; } // Use default resolver for all other URIs return defaultURIResolver(uri);});Important: The resolver must be synchronous—no async/await or Promises. Pre-compute any tokens or transformations before setting the resolver.
Adding Authentication#
A common use case is adding authentication tokens to asset URIs. Generate the token before setting the resolver, then append it as a query parameter:
// Pre-generate token BEFORE setting the resolver (must be synchronous)const authToken = 'demo-jwt-token-123';
// Set resolver that adds authentication to specific endpointsengine.editor.setURIResolver((uri, defaultURIResolver) => { // Only add auth token to URIs pointing to your stable link endpoint if (uri.includes('your-server/image-stable-links/')) { const authenticatedURI = `${uri}?auth=${authToken}`; // eslint-disable-next-line no-console console.log(`\nAuth resolver: Adding token to ${uri}`); // eslint-disable-next-line no-console console.log(` Result: ${authenticatedURI}`); return authenticatedURI; } // Use default resolver for all other URIs return defaultURIResolver(uri);});
// Test authentication with a protected URIconst protectedURI = 'https://your-server/image-stable-links/abc123';engine.editor.getAbsoluteURI(protectedURI);Your server validates the token and redirects to the actual asset (e.g., pre-signed S3 URL). CE.SDK follows redirects automatically.
Removing a Resolver#
Restore default behavior by setting a resolver that delegates to defaultURIResolver:
// Remove the custom resolver to restore default behaviorengine.editor.setURIResolver((uri, defaultURIResolver) => defaultURIResolver(uri));// eslint-disable-next-line no-consoleconsole.log('\n✓ Removed custom resolver - back to default behavior');Key Constraints#
- Synchronous only: No
async/awaitor Promises - Must return absolute URIs: Include scheme (http://, https://, data:)
- One resolver at a time: New calls overwrite previous resolvers
- Delegate unmatched URIs: Pass to
defaultURIResolver()for unchanged paths
Next Steps#
- Configuration — CE.SDK initialization and baseURL settings
- Load Assets from Remote — Load assets from remote URLs and servers