API Communication & useApi

All communication with the backend is centralized through the useApi composable (composables/useApi.ts).

Key Features:

  • Sanctum Client: It wraps useSanctumClient(), ensuring all outgoing requests are automatically authenticated and include required CSRF tokens.
  • Localization Awareness: Automatically injects a Lang header on every request, derived from the current active locale in the store or cookies.
  • Automatic Retries: Implemented with exponential backoff for 429 (Rate Limit) and 500 (Server Error) responses.
  • Standardized Headers: Ensures Accept: application/json and correct Content-Type for both JSON and FormData payloads.
  • Maintenance Mode: Automatically detects 503 status codes and triggers a global maintenance state.