Skip to content

Commit

Permalink
feat(hls): fixed cors and custom header conflict
Browse files Browse the repository at this point in the history
Had to move the crossOrigin check within the xhrSetup function so that cors and custom headers can
be used indepedently of one another

806
  • Loading branch information
jimbeck committed Jan 10, 2019
1 parent 86ea1e1 commit cabf471
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/streaming/vg-hls/vg-hls.ts
Expand Up @@ -56,15 +56,15 @@ export class VgHLS implements OnInit, OnChanges, OnDestroy {
autoStartLoad: this.preload
};

if (this.crossorigin === 'use-credentials') {
this.config.xhrSetup = (xhr, url) => {
// Send cookies
this.config.xhrSetup = (xhr, url) => {
// Send cookies
if (this.crossorigin === 'use-credentials') {
xhr.withCredentials = true;
for (const key of Object.keys(this.vgHlsHeaders)) {
xhr.setRequestHeader(key, this.vgHlsHeaders[key]);
}
};
}
}
for (const key of Object.keys(this.vgHlsHeaders)) {
xhr.setRequestHeader(key, this.vgHlsHeaders[key]);
}
};

this.createPlayer();

Expand All @@ -85,6 +85,9 @@ export class VgHLS implements OnInit, OnChanges, OnDestroy {
if (changes['vgHls'] && changes['vgHls'].currentValue) {
this.createPlayer();
}
else if (changes['vgHlsHeaders'] && changes['vgHlsHeaders'].currentValue) {
// Do nothing. We don't want to create a or destroy a player if the headers change.
}
else {
this.destroyPlayer();
}
Expand Down

0 comments on commit cabf471

Please sign in to comment.