fix(fe/client): sync auth tokens with localStorage and configure dynamic VITE_API_URL
Summary of Changes - Frontend
This PR resolves authentication token persistence issues in mobile WebView environments, dynamic base URL configuration, and error message standardization.
Authentication & Token Management (P0)
-
Token Synchronization: Updated
LoginPageto receive and store actualaccessTokenandrefreshTokenin ZustandauthStoreandlocalStorage. -
Bearer Token Header Injection: Ensured
apiClientrequest interceptor reliably attachesAuthorization: Bearer <token>on all authenticated API calls. -
Robust Token Refresh Loop: Enhanced response interceptor on 401 errors to provide
refreshTokenfallback in POST/auth/refreshbody, ensuring seamless session refreshes in Zalo Mini App WebViews where cookies may be restricted.
Configuration & Portability (P2)
-
Dynamic API Base URL: Replaced hardcoded
http://localhost:7777/api/v1inapiClientandrefreshClientwithimport.meta.env.VITE_API_URL || "http://localhost:7777/api/v1".
i18n & Error Handling (P3)
-
Standardized Service Fallbacks: Normalized
ensureSuccessfallback error strings across all service modules (transaction.service.ts,wallet.service.ts, etc.) to cleanly delegate UI localization togetErrorMessage(error, t(...)).