fix(warn): Refused to get unsafe header "www-authenticate"

This commit is contained in:
Joxit 2021-09-13 09:14:00 +02:00
parent 73613a3b96
commit 21e3ad51af
No known key found for this signature in database
GPG Key ID: F526592B8E012263
3 changed files with 5 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -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",

View File

@ -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;
@ -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;
}