[英]How can I make hls.js send the cookie in request header upon requesting encryption key
我试过了
var config = {
xhrSetup: function (xhr) {
xhr.withCredentials = true; // do send cookies
}
};
但这不起作用。 无论我是否在xhrSetup中启用凭据而不是在密钥请求上启用凭据,都会根据播放列表请求和段请求发送Cookie。 为了保护内容,我需要在分发密钥之前识别用户。 我可以在答案中设置“X-Cookie”,但是如何发送会话cookie?
我像这样设置了一个“X-Cookie”:
var config = {
debug: true,
xhrSetup: function (xhr,url) {
xhr.withCredentials = true; // do send cookie
xhr.setRequestHeader("X-Cookie", read_cookie('SESSIONID'));
}
};
在另一方面它需要
Header set Access-Control-Allow-Headers "X-Cookie"
read_cookie函数:
function read_cookie(key) {
var result;
(result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? (result[1]) : null;
console.log('result : ' + result[1]);
return result[1]
}
有没有办法发送Cookie值?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.