feat(frontend): make baseUrl dynamic for external network access and clear default login inputs
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../services/secure_storage_service.dart';
|
||||
|
||||
/// Central HTTP ApiClient backed by Dio with automatic 401 Unauthorized handling.
|
||||
@@ -7,7 +8,15 @@ class ApiClient {
|
||||
late final Dio _dio;
|
||||
Function()? onUnauthorized;
|
||||
|
||||
static const String baseUrl = 'http://localhost:5000';
|
||||
static String get baseUrl {
|
||||
if (kIsWeb) {
|
||||
final origin = Uri.base.origin;
|
||||
if (origin.isNotEmpty && !origin.contains('null') && !origin.startsWith('file:')) {
|
||||
return origin;
|
||||
}
|
||||
}
|
||||
return const String.fromEnvironment('BACKEND_URL', defaultValue: 'http://localhost:5000');
|
||||
}
|
||||
|
||||
ApiClient(this._storageService) {
|
||||
_dio = Dio(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'package:finlytic_app/core/network/api_client.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:signalr_core/signalr_core.dart';
|
||||
import '../services/secure_storage_service.dart';
|
||||
@@ -21,7 +22,7 @@ class SignalRService extends ChangeNotifier {
|
||||
Stream<List<Map<String, dynamic>>> get healthStream => _healthController.stream;
|
||||
Stream<Map<String, dynamic>> get favoritePricesStream => _favoritePricesController.stream;
|
||||
|
||||
static const String baseUrl = 'http://localhost:5000';
|
||||
static String get baseUrl => ApiClient.baseUrl;
|
||||
|
||||
SignalRService(this.storageService);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user