mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
fix(mobile): .well-known usage (#16577)
fix: .well-known Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
parent
20acdcd884
commit
8b43066632
@ -84,15 +84,17 @@ class ApiService implements Authentication {
|
|||||||
/// port - optional (default: based on schema)
|
/// port - optional (default: based on schema)
|
||||||
/// path - optional
|
/// path - optional
|
||||||
Future<String> resolveEndpoint(String serverUrl) async {
|
Future<String> resolveEndpoint(String serverUrl) async {
|
||||||
final url = sanitizeUrl(serverUrl);
|
String url = sanitizeUrl(serverUrl);
|
||||||
|
|
||||||
if (!await _isEndpointAvailable(serverUrl)) {
|
|
||||||
throw ApiException(503, "Server is not reachable");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for /.well-known/immich
|
// Check for /.well-known/immich
|
||||||
final wellKnownEndpoint = await _getWellKnownEndpoint(url);
|
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
|
// Otherwise, assume the URL provided is the api endpoint
|
||||||
return url;
|
return url;
|
||||||
@ -128,10 +130,12 @@ class ApiService implements Authentication {
|
|||||||
var headers = {"Accept": "application/json"};
|
var headers = {"Accept": "application/json"};
|
||||||
headers.addAll(getRequestHeaders());
|
headers.addAll(getRequestHeaders());
|
||||||
|
|
||||||
final res = await client.get(
|
final res = await client
|
||||||
Uri.parse("$baseUrl/.well-known/immich"),
|
.get(
|
||||||
headers: headers,
|
Uri.parse("$baseUrl/.well-known/immich"),
|
||||||
);
|
headers: headers,
|
||||||
|
)
|
||||||
|
.timeout(const Duration(seconds: 5));
|
||||||
|
|
||||||
if (res.statusCode == 200) {
|
if (res.statusCode == 200) {
|
||||||
final data = jsonDecode(res.body);
|
final data = jsonDecode(res.body);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user