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

Fix Refused to get unsafe header "age" console error in Chrome #3686

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/loader/playlist-loader.ts
Expand Up @@ -686,11 +686,7 @@ class PlaylistLoader {
return;
}

if (
this.checkAgeHeader &&
levelDetails.live &&
this.hls.config.lowLatencyMode
) {
if (this.checkAgeHeader && levelDetails.live) {
const ageHeader = loader.getResponseHeader('age');
levelDetails.ageHeader = ageHeader ? parseFloat(ageHeader) : 0;
// Avoid repeated browser error log `Refused to get unsafe header "age"` when unnecessary or past attempts failed
Expand Down
8 changes: 2 additions & 6 deletions src/utils/xhr-loader.ts
Expand Up @@ -250,12 +250,8 @@ class XhrLoader implements Loader<LoaderContext> {
}

getResponseHeader(name: string): string | null {
if (this.loader) {
try {
return this.loader.getResponseHeader(name);
} catch (error) {
/* Could not get headers */
}
if (this.loader && this.loader.getAllResponseHeaders().indexOf(name) >= 0) {
return this.loader.getResponseHeader(name);
}
return null;
}
Expand Down