Skip to content

Why do captions work beside the MP4 locally but disappear after I move them to a CDN?

Check the video's crossorigin mode and the caption server's actual CORS response before rewriting a subtitle file that stopped loading after a CDN move. A browser can play a remote MP4 while refusing a separately hosted text track. Establish an authorized same-origin baseline, inspect the caption request, then change one hosting condition at a time. Do not disable browser security or expose a private asset to make the test appear successful.

CAPTION DELIVERY: FILES, TRACKS AND BROWSER BEHAVIORAISwapLab team · Editorial methodPublished 3 min read
See the recorded exampleExplore 67 Image SkillsIndependent finishing · Check the actual file
Editorial worksheet excerpt: Same-origin baseline; CDN track; MP4 after mode change. See the complete table and sources below.
Editorial worksheet excerpt: Same-origin baseline; CDN track; MP4 after mode change. See the complete table and sources below.

Caption hosting matrix

This is a resource-loading investigation, not a WebVTT grammar lesson. The track URL normally shares the document's origin unless the parent media element uses the relevant cross-origin mechanism. Server access policy must still agree with the request. A renamed URL, redirected login response or cached failure can obscure that boundary. The distinct deliverable is a small origin-and-response matrix identifying which exact request failed and whether the file received by the browser is the same approved subtitle revision.

Build the evidence

  1. 01

    Prove the caption file independently of the CDN

    Use a minimal known-good VTT beside the review page on one authorized origin and verify it appears with a plain player. Keep the source text identical when moving it to the CDN. Record the page origin, media origin and track origin separately; a subdomain can be a different origin. Check the actual final URL after redirects rather than inferring access from a link that opens in a logged-in tab.

  2. 02

    Inspect request and response together

    The example adds crossorigin=anonymous to the parent video before the track is loaded. The caption server must return an appropriate access-control policy for the requesting page, and the resource must remain accessible under that anonymous request model. Check status, redirects, MIME type and body. A successful HTML error page is not a successful subtitle fetch. Do not copy a signed private URL or authentication token into a public debugging report.

  3. 03

    Retest the whole player without broadening access

    Confirm that the new media request mode also works for the MP4, since a parent attribute can affect more than the text file. If the service requires credentials, design the intended credential policy with its owner rather than swapping anonymous and credentialed requests at random. Repeat the same-origin and CDN cases after cache changes, retain their exact revisions and use the least exposure needed for authorized reviewers.

A bounded example

Illustrative case: a caption file loads from /captions/en.vtt beside the page but fails from a media subdomain. A CDN response report reveals that the anonymous request receives an access-denied body. The transcript can be perfectly valid and still fail. Another case may require a correct cross-origin header while serving the right body. These examples identify diagnostic branches; they are not claims about AISwapLab's hosting setup or a tested CDN compatibility matrix.

Local diagnostic commands

Documentation example only. The example.test hosts are placeholders, not live endpoints. No private access policy, CDN configuration or browser security setting was changed.

html
<!-- Set the mode before loading cross-origin media/track resources. -->
<video controls crossorigin="anonymous" src="https://media.example.test/clip.mp4">
  <track kind="captions" srclang="en" label="English"
         src="https://captions.example.test/en.vtt" default>
</video>
<!-- Replace example origins with authorized endpoints.
     Their CORS/access responses must support the actual page request. -->

Caption hosting matrix

CaseRecordDiagnostic value
Same-origin baselineStatus, body and displayed cuesSeparates syntax/player from cross-origin access
CDN trackFinal URL, request mode and CORS responseIdentifies resource-policy mismatch
MP4 after mode changePlayback and request outcomeAvoids fixing captions while breaking video

Acceptance evidence

  • The same VTT revision passes a same-origin baseline.
  • Page, MP4 and caption origins and redirects are recorded independently.
  • The actual request mode and server policy are compatible.
  • Debug evidence excludes private signed URLs, session cookies and credentials.

Stop condition

Stop if the fix would make private review media public or bypass an access policy. Ask the asset owner for an authorized delivery design. When the baseline fails too, return to syntax and track-selection checks rather than blaming the CDN merely because its hostname changed. Publication should wait for the intended reviewer access path to work.

Sources

Review the result in context.

Compare the recorded example and its documented limitations.

See the recorded example