feat: LAN-first development with optional auth

- Default API URLs now use LAN IPs (192.168.86.149)
- Auth interceptor skips auth when using LAN endpoints
- Production builds override with --dart-define

Development: flutter run -d chrome (no auth needed on LAN)
Production:  flutter build web --dart-define=CORE_API_URL=https://api.schweitz.net

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-31 00:04:04 +01:00
co-authored by Claude Opus 4.5
parent 220ca9bb2a
commit dd6bcbdbda
3 changed files with 43 additions and 3 deletions
+15
View File
@@ -4,9 +4,12 @@ import 'package:dio/dio.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../auth/auth_provider.dart';
import '../config/app_config.dart';
import '../error/app_exception.dart';
/// Adds authentication token to requests.
///
/// Skipped entirely when [AppConfig.requiresAuth] is false (LAN development).
class AuthInterceptor extends Interceptor {
AuthInterceptor(this._ref);
@@ -14,6 +17,12 @@ class AuthInterceptor extends Interceptor {
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
// Skip auth for LAN development
if (!AppConfig.requiresAuth) {
handler.next(options);
return;
}
final authState = _ref.read(authNotifierProvider);
authState.whenData((auth) {
@@ -27,6 +36,12 @@ class AuthInterceptor extends Interceptor {
@override
void onError(DioException err, ErrorInterceptorHandler handler) {
// Skip auth error handling for LAN development
if (!AppConfig.requiresAuth) {
handler.next(err);
return;
}
if (err.response?.statusCode == 401) {
// Token expired - trigger re-authentication
_ref.read(authNotifierProvider.notifier).signOut();