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 axiosMonorepo: "@sumx/http-client": "workspace:*" or file:../sumx-ssr-kit/packages/http-client (run pnpm --filter @sumx/http-client run build after changes).
Documentation map
| Topic | Page |
|---|---|
| Portal wiring, feature services, Next.js | Portal integration |
API_BASE_ENV_CONFIG, createApiBasesFromEnv, factory options | API bases & env |
httpRequestUpdated, createHttpRequest, response types, utilities | Package API |
| Common errors and fixes | Troubleshooting |
Quick start
- Add
api-bases.config.tswith yourNEXT_PUBLIC_*keys. - Build preset URLs with
createApiBasesFromEnvinsrc/axios/bases.ts. - Call
createSumxHttpClient({ apiBaseEnvConfig, apiBases, getEnvValue, … })insrc/axios/axiosInstance.ts. - Use
httpRequestUpdatedfrom services; TanStack Query inactions/. - Add
transpilePackages: ['@sumx/http-client']innext.config.js.
Related
- Packages overview — all kit packages
- Auth — session,
CheckToken,cancelPendingBrowserApiRequestswiring