英文:
<track> Unsafe attempt to load URL () from frame with URL ()
问题
watch.html:1 尝试从 URL file:///C:/subtitle.vtt 加载时存在不安全的行为,来源为 URL file:///C:/watch.html。'file:' URL 被视为唯一的安全来源。
这是我在Chrome浏览器控制台中尝试将字幕添加到视频时遇到的错误。在Internet Explorer中,字幕可以正常工作,没有任何错误消息。我运行的代码是:
<video controls>
<source src="C:\video.mp4" type="video/mp4">
<track src="C:\subtitle.vtt" kind="subtitles" srclang="en" label="English">
</video>
英文:
watch.html:1 Unsafe attempt to load URL file:///C:/subtitle.vtt from frame with URL file:///C:/watch.html. 'file:' URLs are treated as unique security origins.
This is the error I get in Chrome's console when attempting to add the subtitle to the video. The subtitle is working on Internet Explorer without any error message. The code I'm running:
<video controls>
<source src="C:\video.mp4" type="video/mp4">
<track src="C:\subtitle.vtt" kind="subtitles" srclang="en" label="English">
</video>
答案1
得分: 3
解决方案:视频和字幕文件应该在相同的路径下!
英文:
Solution: The video and subtitle file should be in the same path!
答案2
得分: 0
根据我的理解CORSRequestNotHttp:
加载本地文件
来自同一目录及其子目录的本地文件在历史上被视为来自相同的源。这意味着在测试期间,可以从本地目录或子目录加载文件及其所有资源,而不会触发CORS错误。
不幸的是,这带来了安全性问题,正如在这份安全公告中所指出的:CVE-2019-11730。许多浏览器,包括Firefox和Chrome,现在默认将所有本地文件视为具有不透明的来源。因此,加载包括本地资源的本地文件现在会导致CORS错误。
今天唯一的修复方法是设置本地服务器:
需要进行本地测试的开发人员现在应该设置本地服务器。由于所有文件都从相同的方案和域(localhost)提供,它们都具有相同的源,不会触发跨源错误。
英文:
To my understanding of CORSRequestNotHttp:
> <h3>Loading a local file</h3>
>
> Local files from the same directory and subdirectories were
> historically treated as being from the same origin. This meant that a
> file and all its resources could be loaded from a local directory or
> subdirectory during testing, without triggering a CORS error.
>
> Unfortunately this had security implications, as noted in this
> advisory: CVE-2019-11730. Many browsers, including Firefox and Chrome,
> now treat all local files as having opaque origins (by default). As a
> result, loading a local file with included local resources will now
> result in CORS errors.
The only fix today is to set up a local server:
> Developers who need to perform local testing should now set up a local
> server. As all files are served from the same scheme and domain
> (localhost) they all have the same origin, and do not trigger
> cross-origin errors.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论