VionetoVioneto
Back to the magazine

VIONETO MAGAZINE Playback & technology

Diagnose CORS errors for website video

A CORS error can relate to a media file or an additional player request. First, identify the affected address, then update the corresponding configuration.

Two stylized browser tabs featuring a video player and a media tab are linked by a bridge. An orange arrow points to the media side.
At CORS, the specific request is determined by its origin. The external website and an embedded player may have different origins.Image: Vioneto · AI-generated illustration

First, check the affected URL in the browser console and network protocol when encountering a CORS error. A player typically loads multiple components. The error message may refer to the video file, but it could also relate to subtitles, a resource loaded via script, or an additional interface. A single red line does not necessarily indicate which part of playback is affected.

What is meant by Origin

An origin is determined by protocol, host, and port. Therefore, https://kurs.example and https://medien.example are considered different origins. CORS is a mechanism that uses HTTP headers to allow a server to permit cross-origin browser access. A different folder on the same website is still not regarded as a different origin.

MDN: Cross-Origin Resource Sharing and HTTP Permissions

Why a direct video doesn't match every script request

An HTML video element can load a resource from a different origin without CORS enabled. The crossorigin attribute changes the type of request. The MDN documentation distinguishes between anonymous and use-credentials; in anonymous mode, authentication credentials are not sent to a different origin. Therefore, do not add the crossorigin attribute without fully understanding the previous loading path.

Accessing video frames within a Canvas also has additional requirements. Therefore, a video may play visibly even if script-based processing fails. Conversely, a successful direct call in a new tab does not prove that the same URL is correctly configured for a CORS-required request.

MDN: crossorigin and handling of credentials

MDN: The Video Element and Cross-Origin Resources

A concrete example of error troubleshooting

On kurs.example there is a player whose script fetches a resource from medien.example. In the network protocol, record the exact target address, the actual sent origin, and the response status. If the player is running inside a foreign iframe, its own origin might be the sender. Therefore, do not automatically assume the address of the outer kurs page as the expected origin.

Example of a specifically allowed response: Access-Control-Allow-Origin: https://kurs.example

Vioneto example

The example header is part of the response from the relevant resource server. It is not a line you insert as HTML into the post. When multiple allowed origins are present, the operator must implement appropriate response logic. For requests containing access credentials, a wildcard * is insufficient; additional rules and browser cookie restrictions still apply. Adjust these settings in consultation with the responsible administration.

With a specific finding rather than a broad update passed on

  • What specific URL was requested: film, subtitles, or additional service?
  • Which origin was actually sent, and which preload path or cross-origin value is currently in use?
  • What response and redirection were received? An HTML login page is initially different from a successful media response.
  • What actually fails for viewers: the full playback, the subtitle track, or just a supplementary feature?

Detect an HTML response behind the supposed video file

An iframe block enforced by Content Security Policy is not overridden by any CORS header. Maintain separate findings for embedding permissions and resource retrieval. Do not disable browser security as a temporary fix; this would not resolve the issue for actual users.

frame-src and frame-ancestors differ when dealing with blocked video embeds

Topics

Sources and further reading

  1. https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS
  2. https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/crossorigin
  3. https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/video