Skip to content

Commit 87786c2

Browse files
committed
fix(api): centralize and correct dotenv loading
Refactors environment variable handling to be self-contained within the `EnvironmentConfig` class. - The `dotenv` loading logic is moved from `AppDependencies` to `EnvironmentConfig`. - `EnvironmentConfig` now creates a static `DotEnv` instance, loads the `.env` file, and all getters now read from this instance instead of `Platform.environment`. - This ensures that environment variables are loaded and read correctly from a single, reliable source, resolving the issue where variables were not available to the application.
1 parent bd1f880 commit 87786c2

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

lib/src/config/app_dependencies.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'dart:async';
22

3-
import 'package:dotenv/dotenv.dart';
43
import 'package:ht_api/src/config/database_connection.dart';
54
import 'package:ht_api/src/rbac/permission_service.dart';
65
import 'package:ht_api/src/services/auth_service.dart';
@@ -83,10 +82,6 @@ class AppDependencies {
8382
}
8483

8584
Future<void> _init() async {
86-
// 0. Load environment variables from .env file.
87-
DotEnv(includePlatformEnvironment: true).load();
88-
_log.info('Environment variables loaded from .env file.');
89-
9085
// 1. Establish Database Connection.
9186
await DatabaseConnectionManager.instance.init();
9287
final connection = await DatabaseConnectionManager.instance.connection;

0 commit comments

Comments
 (0)