Skip to Content
HTTP ClientOverview

HTTP client (@sumx/http-client)

BFF-aware Axios factory for SumX ERP apps. The kit provides interceptors, /api/bff/{base} routing in the browser, 401 handling, and normalized response shapes. Your app defines which env vars map to which upstream APIs.

Install

pnpm add @sumx/http-client axios

Monorepo: "@sumx/http-client": "workspace:*" or file:../sumx-ssr-kit/packages/http-client (run pnpm --filter @sumx/http-client run build after changes).

Documentation map

TopicPage
Portal wiring, feature services, Next.jsPortal integration
API_BASE_ENV_CONFIG, createApiBasesFromEnv, factory optionsAPI bases & env
httpRequestUpdated, createHttpRequest, response types, utilitiesPackage API
Common errors and fixesTroubleshooting

Quick start

  1. Add api-bases.config.ts with your NEXT_PUBLIC_* keys.
  2. Build preset URLs with createApiBasesFromEnv in src/axios/bases.ts.
  3. Call createSumxHttpClient({ apiBaseEnvConfig, apiBases, getEnvValue, … }) in src/axios/axiosInstance.ts.
  4. Use httpRequestUpdated from services; TanStack Query in actions/.
  5. Add transpilePackages: ['@sumx/http-client'] in next.config.js.
  • Packages overview — all kit packages
  • Auth — session, CheckToken, cancelPendingBrowserApiRequests wiring