File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
dotcom-rendering/src/components Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -185,6 +185,15 @@ export const SelfHostedVideoPlayer = forwardRef(
185185 showPlayIcon ? 'play' : 'pause'
186186 } -${ atomId } `;
187187
188+ /**
189+ * We need CORS enabled to show subtitles on a video as it allows access to the VTT file.
190+ * We don't want a client to not request CORS headers on a video request, then to request
191+ * the same video with CORS headers, as the response could be cached without the headers, which
192+ * will result in the video failing to load. Therefore, we always request CORS headers in production.
193+ */
194+ const requestCORS =
195+ showSubtitles && process . env . NODE_ENV !== 'production' ;
196+
188197 return (
189198 < >
190199 { /* eslint-disable-next-line jsx-a11y/media-has-caption -- Not all videos require captions. */ }
@@ -194,7 +203,7 @@ export const SelfHostedVideoPlayer = forwardRef(
194203 videoStyles ( width , height ) ,
195204 showSubtitles && subtitleStyles ( subtitleSize ) ,
196205 ] }
197- crossOrigin = { showSubtitles ? 'anonymous' : undefined }
206+ crossOrigin = { requestCORS ? 'anonymous' : undefined }
198207 ref = { ref }
199208 tabIndex = { 0 }
200209 data-testid = "self-hosted-video-player"
You can’t perform that action at this time.
0 commit comments