Skip to content

Commit

Permalink
fix(mobile): set custom headers on external url (#14707)
Browse files Browse the repository at this point in the history
when setting up a external server for automatic URL switching ensure all access token AND custom headers are used for the server validaton request
  • Loading branch information
alex-sherwin committed Dec 15, 2024
1 parent dd9feee commit b41bc87
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mobile/lib/services/auth.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,18 @@ class AuthService {

Future<bool> validateAuxilaryServerUrl(String url) async {
final httpclient = HttpClient();
final accessToken = _authRepository.getAccessToken();
bool isValid = false;

try {
final uri = Uri.parse('$url/users/me');
final request = await httpclient.getUrl(uri);
request.headers.add('x-immich-user-token', accessToken);

// add auth token + any configured custom headers
final customHeaders = ApiService.getRequestHeaders();
customHeaders.forEach((key, value) {
request.headers.add(key, value);
});

final response = await request.close();
if (response.statusCode == 200) {
isValid = true;
Expand Down

0 comments on commit b41bc87

Please sign in to comment.