Skip to content

Instantly share code, notes, and snippets.

@f0-x
Created May 1, 2023 05:19
Show Gist options
  • Save f0-x/1f73eaf9f8840fc8c8ebe73fa8d6fc10 to your computer and use it in GitHub Desktop.
Save f0-x/1f73eaf9f8840fc8c8ebe73fa8d6fc10 to your computer and use it in GitHub Desktop.
Custom react-player that supports XHR Headers
<ReactPlayer
url={`/bin.oms/${videoId}`}
config={{
file: {
hlsOptions: {
forceHLS: true,
debug: false,
xhrSetup: function (xhr, url) {
xhr.withCredentials = true; // do send cookies
xhr.setRequestHeader(
"Authorization",
`Basic ${getBasicToken()}`
);
},
},
},
}}
muted={true}
controls={true}
width="100%"
height="100%"
style={{
background: "#191F27",
}}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment