Commit 0369fea1 authored by Rafael Morales's avatar Rafael Morales Committed by Tasso Evangelista

Fix for basic-auth servers connect (#1074)

parent 9ff6b8e5
......@@ -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)),
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment