Skip to content

Conversation

@domlander
Copy link
Contributor

@domlander domlander commented Nov 25, 2025

What does this change?

Add an enableCors prop so that stories do not have to use CORS for video requests.

Why?

Stories containing self-hosted video do not work with crossOrigin set to anonymous. The reason for this is the same as why self-hosted videos do not work when developing locally. It's needed to be able to work with a side-car VTT file.

It is difficult to continue development without being able to use video stories and without the safety net of Chromatic.
Being unable to check stories when developing self-hosted video has led and may lead to introducing bugs.

What are the alternatives

  • Only enable CORS on video requests if in a development environment and there are no subtitles. However, Chromatic is not affected and having a different experience in local and production could lead to bugs.
  • Use a local video. Even if excluded from the production bundle, this means that the video would need to be downloaded whenever the repo is cloned.
  • Use a video publicly available that does not require CORS. This would be a flimsy test if the Guardian does not control the video. To my knowledge, we do not have a video hosted somewhere that fulfils these requirements.
  • Modify the server so that requests from local storybook and Chromatic are permitted. This runs into the same problems that we are having with requesting video when working locally.

Screenshots

https://www.chromatic.com/component?appId=63e251470cfbe61776b0ef19&csfId=components-selfhostedvideo&buildNumber=13841&k=693007b20507c3a940c66af4-1300px-interactive-true&h=2&b=-1

@domlander domlander self-assigned this Nov 25, 2025
@domlander domlander added fronts + curation run_chromatic Runs chromatic when label is applied maintenance Departmental tracking: maintenance work, not a fix or a feature labels Nov 25, 2025
@github-actions
Copy link

github-actions bot commented Nov 25, 2025

@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Nov 25, 2025
@domlander domlander marked this pull request as ready for review November 25, 2025 12:54
@github-actions
Copy link

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

@domlander domlander force-pushed the doml/reenable-self-hosted-video-stories branch from 38110fd to 6de91a0 Compare November 26, 2025 17:47
@domlander domlander added the run_chromatic Runs chromatic when label is applied label Nov 26, 2025
@github-actions
Copy link

github-actions bot commented Nov 26, 2025

@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Nov 26, 2025
@domlander domlander changed the title Re-enable self hosted video stories Re-enable self-hosted video stories Nov 26, 2025
Copy link
Contributor

@Fweddi Fweddi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does setting to crossOrigin to anonymous when there are subtitles, work, when it fails if they aren't subtitles?

showSubtitles && subtitleStyles(subtitleSize),
]}
crossOrigin="anonymous"
crossOrigin={showSubtitles ? 'anonymous' : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does setting to crossOrigin to anonymous when there are subtitles work, but it fails if there aren't subtitles?

Copy link
Contributor Author

@domlander domlander Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting crossOrigin to anonymous is required for subtitles to work because the request for the video will only allow access to a sidecar vtt file if the video request uses CORS headers. CORS headers are not required if there is not a subtitles file.

We experienced issues when we added crossOrigin="anonymous" because some users had the original video request cached before this change (not using CORS headers), then this cached request failed after this change. Therefore I think it's better if always make video requests with CORS headers on production, and only locally omit CORS if it isn't required.

@domlander domlander force-pushed the doml/reenable-self-hosted-video-stories branch 2 times, most recently from 7412ae4 to 3e3428d Compare December 2, 2025 11:50
@domlander domlander added the run_chromatic Runs chromatic when label is applied label Dec 2, 2025
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Dec 2, 2025
@domlander domlander force-pushed the doml/reenable-self-hosted-video-stories branch from 3e3428d to 3115152 Compare December 2, 2025 15:09
@domlander domlander force-pushed the doml/reenable-self-hosted-video-stories branch from 3115152 to f5b5414 Compare December 2, 2025 15:11
@domlander domlander marked this pull request as draft December 2, 2025 15:39
@domlander domlander marked this pull request as ready for review December 2, 2025 16:02
@domlander domlander force-pushed the doml/reenable-self-hosted-video-stories branch from 710b553 to b7db2f3 Compare December 2, 2025 16:02
@domlander domlander added the run_chromatic Runs chromatic when label is applied label Dec 2, 2025
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Dec 2, 2025
@domlander domlander added the run_chromatic Runs chromatic when label is applied label Dec 2, 2025
@domlander domlander force-pushed the doml/reenable-self-hosted-video-stories branch from b7db2f3 to 7f6e13f Compare December 2, 2025 16:30
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Dec 2, 2025
@domlander domlander marked this pull request as draft December 3, 2025 09:46
@domlander domlander added the run_chromatic Runs chromatic when label is applied label Dec 3, 2025
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Dec 3, 2025
@domlander domlander marked this pull request as ready for review December 4, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dotcom-rendering fronts + curation maintenance Departmental tracking: maintenance work, not a fix or a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants