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:
Dennis Nemec
2026-06-18 13:08:18 +02:00
parent f1e48cb177
commit 7544760c34
2 changed files with 15 additions and 58 deletions

View File

@ -1,16 +1,9 @@
/// Endpoint-Konfiguration für das Rust-Backend.
///
/// Diese Übergangs-Konfiguration für die Backend-Migration wird in
/// Phase D durch eine umfassendere Konfigurations-Ablösung verfeinert
/// (Build-Time-Flavor pro Stage etc.).
///
/// **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.
/// Produktiv-Setup: Backend und Keycloak laufen auf dem Host `192.168.1.9`.
/// Es gibt bewusst KEINE Dev-/localhost-/Tunnel-Profile und keine
/// `HL_BACKEND`-Umschaltung mehr — die App zeigt immer auf Prod. So kann kein
/// Build versehentlich auf `localhost` oder eine Dev-IP zeigen.
class BackendConfig {
const BackendConfig({
required this.apiBaseUrl,
@ -24,11 +17,11 @@ class BackendConfig {
/// Realm-Issuer ohne `/.well-known/...`-Suffix —
/// `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
/// 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;
/// Token-Endpoint des Realms — abgeleitet aus dem Issuer.
@ -45,52 +38,16 @@ class BackendConfig {
/// matchen.
final String keycloakRedirectUrl;
/// Default-Konfiguration für lokale Entwicklung gegen das
/// Docker-Compose-Setup (Postgres + Keycloak + Backend).
static const BackendConfig localDev = BackendConfig(
apiBaseUrl: 'http://192.168.0.138:3000',
keycloakIssuerUrl: 'http://192.168.0.138:8080/realms/holzleitner',
/// Produktiv-Konfiguration — einzige Quelle der Wahrheit.
static const BackendConfig prod = BackendConfig(
apiBaseUrl: 'http://192.168.1.9:3000',
keycloakIssuerUrl: 'http://192.168.1.9:8080/realms/holzleitner',
keycloakClientId: 'holzleitner-app',
keycloakRedirectUrl: 'holzleitner://oauth2redirect',
);
/// Konfiguration für USB-Tunnel via `adb reverse` — gedacht für Tests in
/// fremden Netzwerken, in denen das Gerät den Mac nicht über eine LAN-IP
/// erreicht. Alles zeigt auf `localhost`; der Traffic wird über den
/// USB-Bus zum Host getunnelt.
///
/// **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;
/// Aktive Konfiguration. Früher per `--dart-define=HL_BACKEND` zwischen
/// Dev-Profilen (usb-Tunnel / LAN-IP) umschaltbar — entfernt. Das Flag wird
/// jetzt ignoriert; es zählt immer [prod].
static const BackendConfig fromEnvironment = prod;
}

View File

@ -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';
Future<void> main() async {
const config = BackendConfig.localDev;
const config = BackendConfig.prod;
// Health geht ohne Auth — wir nutzen die generierte API-Klasse trotzdem,
// um zu zeigen, dass der Aufruf-Pfad funktioniert.