fix(bunny): read the CDN host from runtime config so Docker images can play video

NEXT_PUBLIC_BUNNY_CDN_URL is inlined into the client bundle at build time, and
the published image is built by CI without it, so the browser had no host to
build a playlist URL from no matter what the operator set in .env.docker. The
player read the empty URL as a stream that had not finished encoding and sat on
'Video Is Processing', retrying forever.

The server knows the value on every request, so the root layout now serialises
the public settings into a JSON script tag and the browser reads them from
there, falling back to the build-time variable for source builds. The
direct-download allow list came through the same broken path and moves with it.

Closes #60
This commit is contained in:
2026-08-20 15:40:21 +03:00
parent 1f2294c7ac
commit 0ff8b42b4a
10 changed files with 254 additions and 10 deletions
+5 -3
View File
@@ -103,11 +103,13 @@ describe('resolvePublicBunnyCdnHostname', () => {
expect(resolvePublicBunnyCdnHostname()).toBeNull();
});
it('reads only the public variable, ignoring the server-only one', () => {
// This runs in the browser bundle, where BUNNY_CDN_URL is never inlined.
it('falls back to the server variable when no config has been injected', () => {
// No document here, which is the SSR pass of a client component: the
// server-only variable is readable and has to yield the same hostname the
// browser will read out of the injected config, or hydration diverges.
vi.stubEnv('BUNNY_CDN_URL', 'https://server.b-cdn.net');
expect(resolvePublicBunnyCdnHostname()).toBeNull();
expect(resolvePublicBunnyCdnHostname()).toBe('server.b-cdn.net');
});
it('reduces the configured public url to its hostname', () => {