0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-03-11 02:23:09 -05:00

fix(mobile): .well-known usage (#16577)

fix: .well-known

Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
waclaw66 2025-03-05 03:25:57 +01:00 committed by GitHub
parent 20acdcd884
commit 8b43066632
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -84,15 +84,17 @@ class ApiService implements Authentication {
/// port - optional (default: based on schema)
/// path - optional
Future<String> resolveEndpoint(String serverUrl) async {
final url = sanitizeUrl(serverUrl);
if (!await _isEndpointAvailable(serverUrl)) {
throw ApiException(503, "Server is not reachable");
}
String url = sanitizeUrl(serverUrl);
// Check for /.well-known/immich
final wellKnownEndpoint = await _getWellKnownEndpoint(url);
if (wellKnownEndpoint.isNotEmpty) return wellKnownEndpoint;
if (wellKnownEndpoint.isNotEmpty) {
url = sanitizeUrl(wellKnownEndpoint);
}
if (!await _isEndpointAvailable(url)) {
throw ApiException(503, "Server is not reachable");
}
// Otherwise, assume the URL provided is the api endpoint
return url;
@ -128,10 +130,12 @@ class ApiService implements Authentication {
var headers = {"Accept": "application/json"};
headers.addAll(getRequestHeaders());
final res = await client.get(
Uri.parse("$baseUrl/.well-known/immich"),
headers: headers,
);
final res = await client
.get(
Uri.parse("$baseUrl/.well-known/immich"),
headers: headers,
)
.timeout(const Duration(seconds: 5));
if (res.statusCode == 200) {
final data = jsonDecode(res.body);