Skip to content

High performance self-hosted photo and video management solution.

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

waclaw668b43066632f1
diff --git a/mobile/lib/services/api.service.dart b/mobile/lib/services/api.service.dart
index 76701491c7..b87e10f020 100644
--- a/mobile/lib/services/api.service.dart
+++ b/mobile/lib/services/api.service.dart
@@ -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);