1

I have a video control on a localhost with closed captions. I have the virtual host static defined that points to the same directory as localhost. Static feeds my media files and has worked forever... except it seems with video caption files.

If the track src is set to static, the captions won't show. Chrome console gives the error:

Unsafe attempt to load URL https://static/file.vtt from the frame with URL https://localhost/page.php. Domains, protocols, and ports must match.

I've tried the advice at the post issue-with-loading-vtt-from-cross-domain and set both values for cross-origin with no luck. Is this a localhost only issue? Any solutions to this?

video.crossorigin="anonymous";
video.crossorigin="use-credentials";
Dan Serbyn
  • 105
  • 5
mseifert
  • 5,390
  • 9
  • 38
  • 100
  • Does your address bar say `https://static/page.php` just before you try to load the VTT? If not, then there will be a CORS error (basically, what you're getting now). Image/video/audio loading is exempt from CORS (though you cannot "sample" the data. eg: no screen grabbing of a video). **Solution**: You fix by making sure `page.php` and `file.vtt` are coming from the in **same domain** (eg: if each file was opened in a new tab then they should have matching server names). – VC.One Aug 29 '22 at 13:27

0 Answers0