由于没有访问控制允许来源而无法播放视频 [英] Videos not playing due to no Access Control Allow Origin

查看:127
本文介绍了由于没有访问控制允许来源而无法播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Web项目,我刚刚开始在Wordpress中使用基于JavaScript的视频播放器.在同一台服务器上使用视频时,视频播放器可以正常工作,但从其他服务器请求视频时,则会在浏览器控制台中引发错误:

I am working on a web project, I just started using a JavaScript based video player in Wordpress. The video player works fine when using videos on the same server but when requesting videos from other servers it throws the error in browser console:

无法加载 http://techslides.com/demos/sample-videos/small.mp4 :所请求的资源上没有"Access-Control-Allow-Origin"标头.因此,不允许访问来源" https://www.gozo.kitchen "

Failed to load http://techslides.com/demos/sample-videos/small.mp4: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.gozo.kitchen' is therefore not allowed access

我正在尝试在其他服务器上访问视频.

I am trying to access the video on a different server.

我尝试查找服务器配置文件,但是找不到它,这是到目前为止我所做的总结:

I have tried locating the server configuration file but I cannot find it here's a summary of what I have done till now :

服务器正在运行linux操作系统.我可以找到nginx.config,但是它为空并允许它使用CORS似乎无法解决问题.视频仍然无法播放.

Server is running the linux operating system. I can find the nginx.config but its empty and enabling it to use CORS does not seem to solve the problem. The video still does not run.

etc目录下没有配置文件.

There is no config file under the etc directory.

我需要启用CORS才能访问其他服务器上的视频.

I need to enable CORS to access videos on other servers.

推荐答案

您正在从另一台服务器请求资源,因此另一台服务器必须允许您使用与您的站点Access-Control-Allow-Origin标头来检索该资源. "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin" rel ="nofollow noreferrer">详细信息.当您使用 --disable-web-security启动chrome时,可以禁用此功能标志,但只能用于测试.

You're requesting a resource from another server so the other server must allow you to retrieve it with an Access-Control-Allow-Origin header that matches your site details. You can disable this when you start chrome with the --disable-web-security flag but that should only be used for testing.

这篇关于由于没有访问控制允许来源而无法播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆