Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

推流到流媒体,rtmp播放正常,hls 播放时 Allow-Control-Allow-Origin 怎么处理? #79

Open
JosonJiang opened this issue Dec 5, 2021 · 1 comment

Comments

@JosonJiang
Copy link

JosonJiang commented Dec 5, 2021

HTTP response code:0 This might be a CORS issue, consider installing Allow-Control-Allow-Origin Chrome Extension
1.065 | A network error occurred: manifestLoadError

NGINX中添加有但是好像没起作用???!

             add_header 'Access-Control-Allow-Origin' '*';
             add_header "Access-Control-Allow-Credentials" "true";
             add_header "Access-Control-Allow-Methods" "*";
             add_header "Access-Control-Allow-Headers" "Content-Type,Access-Token";
             add_header "Access-Control-Expose-Headers" "*";

参考文档————————————————
版权声明:本文为CSDN博主「ENVON」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/envon123/article/details/83270277`

修改如下:

                add_header 'Access-Control-Allow-Origin' $http_origin;
		add_header 'Access-Control-Allow-Credentials' 'true';
		add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
		add_header 'Access-Control-Allow-Headers' 'DNT,web-token,app-token,Authorization,Accept,Origin,Keep-Alive,User-Agent,X-Mx-ReqToken,X-Data-Type,X-Auth-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
		add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
		if ($request_method = 'OPTIONS') {
			add_header 'Access-Control-Max-Age' 1728000;
			add_header 'Content-Type' 'text/plain; charset=utf-8';
			add_header 'Content-Length' 0;
			return 204;
		}

任然报错

测似使用地址:

https://hls-js.netlify.app/demo/
https://developer-tools.jwplayer.com/stream-tester

安装 Google 跨越插件也不行

video-dev/hls.js#1117

有人遇见没?Centos 系统

@JosonJiang JosonJiang changed the title Allow-Control-Allow-Origin 怎么处理? 推流到流媒体,rtmp播放正常,hls 播放时 Allow-Control-Allow-Origin 怎么处理? Dec 5, 2021
@lystormenvoy
Copy link

options里也要的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants