Cors中发送原始Cookie不适用于VideoJS

问题描述 投票:0回答:1

我有以下子域:

  1. stream.example.com
  2. sub.example.com

两个域都具有SSL证书并且有效。我正在使用具有videoJS 7.6.6库的http_streaming

sub.example.com上,有一个视频标签,用于将破折号清单设置为包含指向stream.example.com的链接的源。当向sub.example.com链接发出请求时,VideoJS需要包含来自stream.example.com的laravel cookie,但这不会发生当我从开发人员控制台下载HAR result时,在请求中看到空的cookie。

我的VideoJS HTML

<video-js id="player" class="video-js vjs-big-play-centered">
            <source src="data:application/dash+xml;charset=utf-8;base64,......." type="application/dash+xml" crossorigin="use-credentials">
        </video-js>

mainifest有效,并且包含stream.example.com个URL

VideoJS

player = window.player = videojs('player', {
            html5: {
                hls: {
                    withCredentials: true
                }
            },
            controls : true,
            fluid: true,
            controlBar: {
                children: ['playToggle', 'volumePanel', 'currentTimeDisplay', 'timeDivider', 'durationDisplay', 'progressControl', 'liveDisplay', 'seekToLive', 'remainingTimeDisplay', 'customControlSpacer', 'playbackRateMenuButton', 'chaptersButton', 'descriptionsButton', 'subsCapsButton', 'audioTrackButton', 'settingMenuButton', 'qualitySelector','fullscreenToggle']
            },
            preload : 'auto',
            poster : '',
        });
        player.hotkeys({
            volumeStep: 0.1,
            seekStep: 5,
            alwaysCaptureHotkeys: true
        });

        var myplugin = window.myplugin = player.myplugin();
    }(window, window.videojs));

[stream.example.com具有以下标题,当我在浏览器选项卡中查看视频链接时。

accept-ranges: bytes
access-control-allow-credentials: 1
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Content-Length, Authorization,Range
access-control-allow-methods: GET, PUT, POST, DELETE, OPTIONS
access-control-allow-origin: https://sub.example.com
access-control-max-age: 86400
cache-control: private, max-age=18350
content-length: 69688791
content-range: bytes 0-69688790/69688791
content-type: video/mp4

我下载了HAR请求,以了解videoJS如何发出请求

  {
    "startedDateTime": "2020-03-15T07:53:57.647Z",
    "time": 1.1023430000004737,
    "request": {
      "method": "GET",
      "url": "https://stream.example.com/s/......",
      "httpVersion": "",
      "headers": [
        {
          "name": "Referer",
          "value": "https://sub.example.com/"
        },
        {
          "name": "Sec-Fetch-Dest",
          "value": "empty"
        },
        {
          "name": "User-Agent",
          "value": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36"
        },
        {
          "name": "DNT",
          "value": "1"
        },
        {
          "name": "Range",
          "value": "bytes=741-2044"
        }
      ],
      "queryString": [
        {
          "name": "u",
          "value": "....."
        }
      ],
      "cookies": [], // <-- The cookies are EMPTY
      "headersSize": -1,
      "bodySize": 0
    },
javascript laravel cookies cross-domain video.js
1个回答
0
投票

我假设您需要将Cookie设为对所有子域均有效“ share”,如how to share cookie between subdomain and domain中所述:]

如果您使用以下内容,它将在两个域上都可用:

Set-Cookie: name=value; domain=example.com

其他都很好看。

© www.soinside.com 2019 - 2024. All rights reserved.