fix(front): en mode debug sans API_BASE_URL, cibler le back prod (web inclus)
Évite Uri.base.origin sur flutter run -d chrome qui visait le serveur de dev. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
7ba8d51668
commit
919148fa75
@ -1,18 +1,21 @@
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
import 'package:flutter/foundation.dart' show kDebugMode, kIsWeb;
|
||||
|
||||
class Env {
|
||||
/// Base URL de l’API (sans `/api/v1`).
|
||||
///
|
||||
/// - **Web prod** : par défaut on utilise [Uri.base.origin] (même schéma + hôte que la page),
|
||||
/// ce qui évite les blocages « mixed content » (ex. page en `http://` vs API en `https://`)
|
||||
/// et les builds où `--dart-define=API_BASE_URL` ne serait pas passé.
|
||||
/// - **Web dev** : surcharger avec `--dart-define=API_BASE_URL=http://localhost:3000` (ou l’URL du back).
|
||||
/// - **Mobile** : défaut `https://app.ptits-pas.fr` ou `API_BASE_URL` en `--dart-define`.
|
||||
/// - **`API_BASE_URL` en `--dart-define`** : prioritaire (back local, staging, etc.).
|
||||
/// - **Mode debug sans define** : toujours **`https://app.ptits-pas.fr`** (web inclus) pour
|
||||
/// pointer sur le back de prod depuis l’IDE / `flutter run`.
|
||||
/// - **Web release / profile sans define** : [Uri.base.origin] (même hôte que la page déployée).
|
||||
/// - **Mobile release / profile sans define** : `https://app.ptits-pas.fr`.
|
||||
static String get apiBaseUrl {
|
||||
const fromEnv = String.fromEnvironment('API_BASE_URL');
|
||||
if (fromEnv.isNotEmpty) {
|
||||
return fromEnv;
|
||||
}
|
||||
if (kDebugMode) {
|
||||
return 'https://app.ptits-pas.fr';
|
||||
}
|
||||
if (kIsWeb) {
|
||||
return Uri.base.origin;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user