Problem
In lib/services/api_service.dart (around line ~35), the Dio interceptor checks for errors and simply passes them on:
onError: (error, handler) {
handler.next(error);
},
If the session token expires, or the backend clears the in-memory session (which happens on every backend restart), API calls start returning 401 Unauthorized.
There is no central logic to clear the getSessionToken in StorageService and redirect the user back to the profile picker. As a result, the user receives mysterious Failed to load errors and cannot switch profiles or log in again unless they clear app data.
Suggested Fix
Update the Dio onError interceptor to detect 401 responses. If detected, call a callback to clear the token and force navigation to the login/profile selection route (e.g. using a global NavigatorState key or Riverpod provider).
Problem
In
lib/services/api_service.dart(around line ~35), the Dio interceptor checks for errors and simply passes them on:If the session token expires, or the backend clears the in-memory session (which happens on every backend restart), API calls start returning
401 Unauthorized.There is no central logic to clear the
getSessionTokeninStorageServiceand redirect the user back to the profile picker. As a result, the user receives mysteriousFailed to loaderrors and cannot switch profiles or log in again unless they clear app data.Suggested Fix
Update the Dio
onErrorinterceptor to detect401responses. If detected, call a callback to clear the token and force navigation to the login/profile selection route (e.g. using a globalNavigatorStatekey or Riverpod provider).