feat(server): Improve server health checks and authentication flow

This commit is contained in:
cogwheel0
2025-11-26 15:25:02 +05:30
parent 9b69290589
commit 44d1cc99b4
7 changed files with 166 additions and 35 deletions

View File

@@ -219,7 +219,7 @@ class ApiService {
return parsed;
}
// Health check
/// Basic health check - just verifies the server is reachable.
Future<bool> checkHealth() async {
try {
final response = await _dio.get('/health');
@@ -229,6 +229,35 @@ class ApiService {
}
}
/// Verifies this is actually an OpenWebUI server by checking the /api/config
/// endpoint for OpenWebUI-specific fields (version, status, features).
///
/// Returns `true` if the server appears to be a valid OpenWebUI instance.
Future<bool> verifyIsOpenWebUIServer() async {
try {
final response = await _dio.get('/api/config');
if (response.statusCode != 200) {
return false;
}
final data = response.data;
if (data is! Map<String, dynamic>) {
return false;
}
// Check for OpenWebUI-specific fields
// The /api/config endpoint always returns these fields on OpenWebUI
final hasStatus = data['status'] == true;
final hasVersion =
data['version'] is String && (data['version'] as String).isNotEmpty;
final hasFeatures = data['features'] is Map;
return hasStatus && hasVersion && hasFeatures;
} catch (e) {
return false;
}
}
// Enhanced health check with model availability
Future<Map<String, dynamic>> checkServerStatus() async {
final result = <String, dynamic>{