Function: prefixedCdnBase()
ts
function prefixedCdnBase(publicKey, cdnBase?): string;Defined in: cdn-base/prefixed.ts:76
Your project's prefixed CDN base: <prefix>.ucarecd.net, computed synchronously. Prefer this one on the server, where it uses node:crypto and costs ~0.2 kB, or anywhere awaiting is awkward — a config module's top-level export, a synchronous render path, a React Native bundle.
In a browser it carries its own SHA-256 (~1 kB), because crypto.subtle only answers asynchronously and no synchronous code can wait for a promise. If you can await, prefixedCdnBaseAsync is the cheaper browser choice.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
publicKey | string | undefined | The project's public key. |
cdnBase? | string | PREFIX_CDN_BASE | The zone to prefix; defaults to PREFIX_CDN_BASE. Pass one explicitly only if you deliver from a different prefixed zone. |
Returns
string
The prefixed base, without a trailing slash.
Example
ts
prefixedCdnBase('demopublickey')
// https://1s4oyld5dc.ucarecd.net
cdn.base(prefixedCdnBase('demopublickey')).file(uuid).href
// https://1s4oyld5dc.ucarecd.net/:uuid/