Allow well-known to fail, it is optional after all

This commit is contained in:
Michael Telatynski 2021-07-14 14:19:05 +01:00
parent 2acec4f124
commit 5c2f2b0684
1 changed files with 11 additions and 7 deletions

View File

@ -24,13 +24,17 @@ export async function resolveServer(request, baseURL) {
baseURL = `https://${baseURL}`;
}
{
const {status, body} = await request(`${baseURL}/.well-known/matrix/client`, {method: "GET"}).response();
if (status === 200) {
const proposedBaseURL = body?.['m.homeserver']?.base_url;
if (typeof proposedBaseURL === "string") {
baseURL = noTrailingSlash(proposedBaseURL);
}
}
try {
const {status, body} = await request(`${baseURL}/.well-known/matrix/client`, {method: "GET"}).response();
if (status === 200) {
const proposedBaseURL = body?.['m.homeserver']?.base_url;
if (typeof proposedBaseURL === "string") {
baseURL = noTrailingSlash(proposedBaseURL);
}
}
} catch (e) {
console.warn("Failed to fetch ${baseURL}/.well-known/matrix/client", e);
}
}
{
const {status} = await request(`${baseURL}/_matrix/client/versions`, {method: "GET"}).response();