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

View file

@ -24,6 +24,7 @@ export async function resolveServer(request, baseURL) {
baseURL = `https://${baseURL}`; baseURL = `https://${baseURL}`;
} }
{ {
try {
const {status, body} = await request(`${baseURL}/.well-known/matrix/client`, {method: "GET"}).response(); const {status, body} = await request(`${baseURL}/.well-known/matrix/client`, {method: "GET"}).response();
if (status === 200) { if (status === 200) {
const proposedBaseURL = body?.['m.homeserver']?.base_url; const proposedBaseURL = body?.['m.homeserver']?.base_url;
@ -31,6 +32,9 @@ export async function resolveServer(request, baseURL) {
baseURL = noTrailingSlash(proposedBaseURL); 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(); const {status} = await request(`${baseURL}/_matrix/client/versions`, {method: "GET"}).response();