Skip to main content

Configure from your server

Fetch backendEndpoints, streamKey, and a token from your own endpoint instead of hardcoding them

To move past the Quickstart's pasted-in values, have your page ask your own backend for the Native Frame connection values — backendEndpoints, streamKey, and a user token — check that each one arrived, and only then hand them to the SDK.

Prerequisites​

  • A server that follows Create Streams Server-Side: it holds the service-account JWT, creates streams, and mints a short-lived user JWT per session.
  • A finished Quickstart, so you know where backendEndpoints, streamKey, and auth go in createCall and requestPlayer.
  • A config endpoint on that server. This guide uses GET /api/stream-config, answering with JSON in this shape:
{
"backendEndpoints": ["https://your-subdomain.example.com"],
"streamKey": "your-stream-key",
"manifestUrl": "https://.../<streamId>.json",
"token": "<short-lived user JWT>"
}

manifestUrl only applies to a viewer page; a broadcaster page can ignore it. Treat it as opaque and pass it to the playback SDK verbatim — see Manifests.

Which values belong in the browser​

ValueBrowser-safe?Why
backendEndpointsYesPublic host names the SDK connects to.
streamKeyYes, on the broadcaster's pageNames the stream to publish to; the token is what authorizes publishing.
manifestUrlYes, on the viewer's pageComplete URL the viewer's player polls; opaque, never construct or modify it.
User JWT (token)YesShort-lived and scoped to one user and one role, such as broadcaster or viewer.
Service-account JWTNoLong-lived, with broad permissions. It stays on the server and only mints user JWTs — see Service Account JWTs vs User JWTs.

Procedure​

  1. Fetch the configuration before you touch the SDK. Send the user's session cookie or header so your server can mint a token for that user.
async function loadStreamConfig() {
const response = await fetch('/api/stream-config', { credentials: 'include' });
if (!response.ok) {
throw new Error(`Config request failed with HTTP ${response.status}`);
}
return response.json();
}
  1. Validate each value. Destructure the response and stop at the first missing field, naming it, so an empty {} response reads as "missing backendEndpoints" instead of a stack trace from inside the SDK.
function validateStreamConfig(config) {
const { backendEndpoints, streamKey, manifestUrl, token } = config ?? {};
if (!Array.isArray(backendEndpoints) || backendEndpoints.length === 0) {
throw new Error('Stream config is missing backendEndpoints');
}
if (typeof streamKey !== 'string' || streamKey === '') {
throw new Error('Stream config is missing streamKey');
}
if (manifestUrl != null && (typeof manifestUrl !== 'string' || manifestUrl === '')) {
throw new Error('Stream config has an invalid manifestUrl');
}
if (typeof token !== 'string' || token === '') {
throw new Error('Stream config is missing token');
}
return { backendEndpoints, streamKey, manifestUrl, token };
}
  1. Show the error where the reader can see it. Render the message into the page rather than leaving it in the console.
function showConfigError(error) {
const box = document.getElementById('config-error');
box.textContent = error.message;
box.hidden = false;
}
  1. Pass the validated values to the SDK. Only now create the auth client and then the call or the player.
import { createCall, requestPlayer, BaseAuthClient } from 'vdc-cdn';

let config;
try {
config = validateStreamConfig(await loadStreamConfig());
} catch (error) {
showConfigError(error);
throw error;
}

const authClient = new BaseAuthClient(config.token);

// Broadcaster page
const call = await createCall({
streamKey: config.streamKey,
backendEndpoints: config.backendEndpoints,
auth: authClient,
user: { userId: 'user-123', displayName: 'Broadcaster' },
});

// Viewer page: your server can return the manifest URL the same way.
// Pass the same auth client when the stream is private.
const player = await requestPlayer(config.manifestUrl, { auth: authClient, autoPlay: true });

Result​

The page loads with no pasted-in values. With a complete response, the broadcaster starts a call, or the viewer's player attaches, exactly as in the Quickstart. With an incomplete response such as {}, the page shows Stream config is missing backendEndpoints before any SDK call runs, and nothing else happens.

Troubleshooting​

The page shows "Stream config is missing token"​

Your endpoint answered, but without a user JWT. Check that the server mints a token for the signed-in user on this request and that the JSON key is spelled token. The service-account JWT is not a substitute; it must never reach the browser.

The SDK reports a permission error after the config loads​

The token arrived but carries the wrong scope for the page: a viewer token cannot broadcast, and a public-stream viewer token cannot open a private stream. Mint the scope the page needs — see Token Setup.