0

I was getting the following browser console error:

Unsafe attempt to load URL https://myprivatecdn.mydomain.com/blaa/media/1488/someVideoCaptions.vtt from frame with URL https://mylocalmachine.mydomain.com/blaa/contentSetup... Domains, protocols and ports must match.

With this code:

<video playsinline="" controls="" preload="auto" width="640" height="264">
  <source src="https://myprivatecdn.mydomain.com/blaa/media/1488/someVideo.mp4" type="video/mp4">
  <track kind="captions" src="https://myprivatecdn.mydomain.com/blaa/media/1488/someVideoCaptions.vtt" default>
</video>

Video played but it was having a problem showing the captions.
Works fine when I served all files from local machine.

Both the video and captions files are on an S3 bucket with restricted access via CloudFront signed cookies only.
I've a CORS policy attached to it sending "Access-Control-Allow-Origin: *" back in response for example.

So I added crossorigin="anonymous" to the video tag after some googling.

Now neither the video or captions files are served, getting 403 for both of them with the following text in the response:

<?xml version="1.0" encoding="UTF-8"?><Error><Code>MissingKey</Code><Message>Missing Key-Pair-Id query parameter or cookie value</Message></Error>
Thomas Buckley
  • 5,836
  • 19
  • 62
  • 110
  • VTT must be in same location as the HTML file. Can you use PHP on your server? If yes, then use it to read & echo back the VTT file. Example: `` ... This assumes that your **mypage.html** with a ` – VC.One Jun 21 '23 at 06:38
  • @VC.One Can't use PHP on my server. The captions work fine when the Vtt is served from a local windows directory which is not in the same location as the HTML file with the Video tag. Are you saying the Vtt file must be in the same location as the HTML file rendering it when using a CDN? Would you have a link to some spec that explains this behavior for the tracks tag? Thanks – Thomas Buckley Jun 21 '23 at 15:02
  • I think you may be getting into the complicated world of CORS with signed S3 - it may be worth looking at some issues/answers related to that, but bear in mind the behaviour can change over time and across browsers sometimes. - e.g https://stackoverflow.com/q/63582233/334402 – Mick Jun 22 '23 at 09:45

0 Answers0