Skip to content

Commit

Permalink
Fix for basic-auth servers connect (#1074)
Browse files Browse the repository at this point in the history
  • Loading branch information
Drintios authored and tassoevan committed Feb 14, 2019
1 parent 9ff6b8e commit 0369fea
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/scripts/servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,16 @@ class Servers extends EventEmitter {
}

async validateHost(hostUrl, timeout = 5000) {
const headers = new Headers();

if (hostUrl.includes('@')) {
const url = new URL(hostUrl);
hostUrl = url.origin;
headers.set('Authorization', `Basic ${ btoa(`${ url.username }:${ url.password }`) }`);
}

const response = await Promise.race([
fetch(`${ hostUrl }/api/info`),
fetch(`${ hostUrl }/api/info`, { headers }),
new Promise((resolve, reject) => setTimeout(() => reject('timeout'), timeout)),
]);

Expand Down

0 comments on commit 0369fea

Please sign in to comment.