chore(config): Frontend auf Prod (192.168.1.9) + Dev-Profile entfernt
- backend_config: einziges Profil 'prod' (API + Keycloak 192.168.1.9); HL_BACKEND-Weiche/usbReverse entfernt -> kein versehentliches localhost/Dev-Routing - smoke_test_api: BackendConfig.prod statt entferntem .localDev Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -1,16 +1,9 @@
|
|||||||
/// Endpoint-Konfiguration für das Rust-Backend.
|
/// Endpoint-Konfiguration für das Rust-Backend.
|
||||||
///
|
///
|
||||||
/// Diese Übergangs-Konfiguration für die Backend-Migration wird in
|
/// Produktiv-Setup: Backend und Keycloak laufen auf dem Host `192.168.1.9`.
|
||||||
/// Phase D durch eine umfassendere Konfigurations-Ablösung verfeinert
|
/// Es gibt bewusst KEINE Dev-/localhost-/Tunnel-Profile und keine
|
||||||
/// (Build-Time-Flavor pro Stage etc.).
|
/// `HL_BACKEND`-Umschaltung mehr — die App zeigt immer auf Prod. So kann kein
|
||||||
///
|
/// Build versehentlich auf `localhost` oder eine Dev-IP zeigen.
|
||||||
/// **Werte für lokale Entwicklung:**
|
|
||||||
/// * iOS-Simulator + macOS-Host: `http://localhost:...`
|
|
||||||
/// * Android-Emulator: `http://10.0.2.2:...`
|
|
||||||
/// * Echtes Gerät im LAN: `http://<host-IP>:...`
|
|
||||||
///
|
|
||||||
/// Default ist iOS-Simulator-tauglich; für Android-Build vor dem
|
|
||||||
/// Compile umstellen oder per Build-Flag injizieren.
|
|
||||||
class BackendConfig {
|
class BackendConfig {
|
||||||
const BackendConfig({
|
const BackendConfig({
|
||||||
required this.apiBaseUrl,
|
required this.apiBaseUrl,
|
||||||
@ -24,11 +17,11 @@ class BackendConfig {
|
|||||||
|
|
||||||
/// Realm-Issuer ohne `/.well-known/...`-Suffix —
|
/// Realm-Issuer ohne `/.well-known/...`-Suffix —
|
||||||
/// `flutter_appauth` hängt das selbst an für die Discovery.
|
/// `flutter_appauth` hängt das selbst an für die Discovery.
|
||||||
/// Beispiel: `http://localhost:8080/realms/holzleitner`.
|
/// Beispiel: `http://192.168.1.9:8080/realms/holzleitner`.
|
||||||
///
|
///
|
||||||
/// **Achtung:** Keycloak prägt das `iss`-Claim aus dem Hostnamen
|
/// **Achtung:** Keycloak prägt das `iss`-Claim aus dem Hostnamen
|
||||||
/// dieser URL. Das Backend erwartet exakt diesen String als
|
/// dieser URL. Das Backend erwartet exakt diesen String als
|
||||||
/// `KEYCLOAK_ISSUER_URL`. Mismatch → 401 mit `invalid issuer`.
|
/// `issuer_url`. Mismatch → 401 mit `invalid issuer`.
|
||||||
final String keycloakIssuerUrl;
|
final String keycloakIssuerUrl;
|
||||||
|
|
||||||
/// Token-Endpoint des Realms — abgeleitet aus dem Issuer.
|
/// Token-Endpoint des Realms — abgeleitet aus dem Issuer.
|
||||||
@ -45,52 +38,16 @@ class BackendConfig {
|
|||||||
/// matchen.
|
/// matchen.
|
||||||
final String keycloakRedirectUrl;
|
final String keycloakRedirectUrl;
|
||||||
|
|
||||||
/// Default-Konfiguration für lokale Entwicklung gegen das
|
/// Produktiv-Konfiguration — einzige Quelle der Wahrheit.
|
||||||
/// Docker-Compose-Setup (Postgres + Keycloak + Backend).
|
static const BackendConfig prod = BackendConfig(
|
||||||
static const BackendConfig localDev = BackendConfig(
|
apiBaseUrl: 'http://192.168.1.9:3000',
|
||||||
apiBaseUrl: 'http://192.168.0.138:3000',
|
keycloakIssuerUrl: 'http://192.168.1.9:8080/realms/holzleitner',
|
||||||
keycloakIssuerUrl: 'http://192.168.0.138:8080/realms/holzleitner',
|
|
||||||
keycloakClientId: 'holzleitner-app',
|
keycloakClientId: 'holzleitner-app',
|
||||||
keycloakRedirectUrl: 'holzleitner://oauth2redirect',
|
keycloakRedirectUrl: 'holzleitner://oauth2redirect',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Konfiguration für USB-Tunnel via `adb reverse` — gedacht für Tests in
|
/// Aktive Konfiguration. Früher per `--dart-define=HL_BACKEND` zwischen
|
||||||
/// fremden Netzwerken, in denen das Gerät den Mac nicht über eine LAN-IP
|
/// Dev-Profilen (usb-Tunnel / LAN-IP) umschaltbar — entfernt. Das Flag wird
|
||||||
/// erreicht. Alles zeigt auf `localhost`; der Traffic wird über den
|
/// jetzt ignoriert; es zählt immer [prod].
|
||||||
/// USB-Bus zum Host getunnelt.
|
static const BackendConfig fromEnvironment = prod;
|
||||||
///
|
|
||||||
/// **Setup vor dem Start (Gerät per USB angesteckt):**
|
|
||||||
/// ```
|
|
||||||
/// adb reverse tcp:3000 tcp:3000 # Rust-API
|
|
||||||
/// adb reverse tcp:8080 tcp:8080 # Keycloak
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// **Backend-Voraussetzungen**, damit das OIDC-Login funktioniert:
|
|
||||||
/// * Backend-Env `KEYCLOAK_ISSUER_URL=http://localhost:8080/realms/holzleitner`
|
|
||||||
/// (muss exakt mit [keycloakIssuerUrl] matchen, sonst 401 `invalid issuer`).
|
|
||||||
/// * Keycloak muss den Issuer als `localhost` ausgeben — z. B. via
|
|
||||||
/// `KC_HOSTNAME_URL=http://localhost:8080` (oder Frontend-URL im Realm),
|
|
||||||
/// sonst prägt es den Container-Hostnamen ins `iss`-Claim.
|
|
||||||
/// * Der `holzleitner://oauth2redirect`-Redirect bleibt unverändert (das
|
|
||||||
/// Custom-Scheme ist netzwerk-unabhängig).
|
|
||||||
///
|
|
||||||
/// Aktivieren ohne Code-Edit:
|
|
||||||
/// ```
|
|
||||||
/// flutter run --dart-define=HL_BACKEND=usb
|
|
||||||
/// ```
|
|
||||||
static const BackendConfig usbReverse = BackendConfig(
|
|
||||||
apiBaseUrl: 'http://localhost:3000',
|
|
||||||
keycloakIssuerUrl: 'http://localhost:8080/realms/holzleitner',
|
|
||||||
keycloakClientId: 'holzleitner-app',
|
|
||||||
keycloakRedirectUrl: 'holzleitner://oauth2redirect',
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Wählt die Config anhand des Compile-Time-Flags `HL_BACKEND`:
|
|
||||||
/// * `usb` → [usbReverse] (adb-reverse-Tunnel über localhost)
|
|
||||||
/// * sonst → [localDev] (LAN-IP, Default)
|
|
||||||
///
|
|
||||||
/// So muss für einen Netzwerkwechsel nur das Build-Flag gesetzt werden,
|
|
||||||
/// nicht der Quellcode angefasst.
|
|
||||||
static const BackendConfig fromEnvironment =
|
|
||||||
String.fromEnvironment('HL_BACKEND') == 'usb' ? usbReverse : localDev;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import 'package:hl_lieferservice/data/network/dev_password_grant_token_provider.
|
|||||||
import 'package:hl_lieferservice/data/network/holzleitner_api_factory.dart';
|
import 'package:hl_lieferservice/data/network/holzleitner_api_factory.dart';
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
const config = BackendConfig.localDev;
|
const config = BackendConfig.prod;
|
||||||
|
|
||||||
// Health geht ohne Auth — wir nutzen die generierte API-Klasse trotzdem,
|
// Health geht ohne Auth — wir nutzen die generierte API-Klasse trotzdem,
|
||||||
// um zu zeigen, dass der Aufruf-Pfad funktioniert.
|
// um zu zeigen, dass der Aufruf-Pfad funktioniert.
|
||||||
|
|||||||
Reference in New Issue
Block a user