feat: enable Windows app internet access and improve server discovery
This commit is contained in:
1 parent
443a930b57
commit
aebfeca342
5 files changed
+52
-19
No files matched your search
@@ -2,8 +2,8 @@ class ApiConstants {
|
||||
static const int port = 18484;
|
||||
|
||||
// Runtime-mutable base URL — set by ServerDiscoveryService before first use.
|
||||
// Default: localhost for Windows desktop, Android will discover via LAN scan.
|
||||
static String _baseUrl = 'http://127.0.0.1:$port/api';
|
||||
// Default: remote internet/configured server IP or domain.
|
||||
static String _baseUrl = 'http://198.252.107.197:$port/api';
|
||||
|
||||
static String get baseUrl => _baseUrl;
|
||||
|
||||
|
||||
@@ -33,9 +33,12 @@ class ServerDiscoveryService {
|
||||
|
||||
static Future<bool> ping(String baseUrl) async {
|
||||
try {
|
||||
final rootUrl = baseUrl
|
||||
.replaceAll(RegExp(r'/+$'), '')
|
||||
.replaceAll(RegExp(r'/api$'), '');
|
||||
final dio = Dio(
|
||||
BaseOptions(
|
||||
baseUrl: baseUrl,
|
||||
baseUrl: rootUrl,
|
||||
connectTimeout: _pingTimeout,
|
||||
receiveTimeout: _pingTimeout,
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user