Skip to content

Commit

Permalink
fix(warn): Refused to get unsafe header "www-authenticate"
Browse files Browse the repository at this point in the history
  • Loading branch information
Joxit committed Sep 13, 2021
1 parent 73613a3 commit 21e3ad5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/docker-registry-ui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docker-registry-ui",
"version": "2.0.8",
"version": "2.0.9",
"scripts": {
"start": "ROLLUP_SERVE=true rollup -c -w",
"build": "rollup -c",
Expand Down
5 changes: 3 additions & 2 deletions src/scripts/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export class Http {
case 'loadend': {
self.oReq.addEventListener('loadend', function () {
if (this.status == 401 && !this.withCredentials) {
const tokenAuth = parseAuthenticateHeader(this.getResponseHeader('www-authenticate'));
const tokenAuth =
this.hasHeader('www-authenticate') && parseAuthenticateHeader(this.getResponseHeader('www-authenticate'));
self.onAuthentication(tokenAuth, (bearer) => {
const req = new XMLHttpRequest();
req._url = self._url;
Expand All @@ -65,7 +66,7 @@ export class Http {
req.setRequestHeader(key, self._headers[key]);
}
if (bearer && bearer.token) {
req.setRequestHeader('Authorization', `Bearer ${bearer.token}`)
req.setRequestHeader('Authorization', `Bearer ${bearer.token}`);
} else {
req.withCredentials = true;
}
Expand Down

0 comments on commit 21e3ad5

Please sign in to comment.