1.7 KiB
1.7 KiB
0066 The browser calls the API directly
Status: Accepted · Area: architecture · Date: 2026-10-16 · Decided by: user · Supersedes: 0065
Context
Each app's next.config.ts rewrote NEXT_PUBLIC_CLIENT_END_POINT (/api) to INTERNAL_END_POINT, so all browser API traffic, uploads included, passed through the Next.js server (0018, 0065). The user removed the rewrite.
Decision
- Every app's env keeps
INTERNAL_END_POINT(server only) andNEXT_PUBLIC_CLIENT_END_POINT(public), with the same names in bull, bear and wall-street-plaza. Both are origins with no path. NEXT_PUBLIC_CLIENT_END_POINTis the API's public origin (the gateway, or admin-api in the admin app). The client bootstrap's HTTP client calls it directly withcredentials: 'include', and the platform'sapiBaseUrl(media and upload URLs) uses it.INTERNAL_END_POINTis the API's origin from inside the deployment network. The server bootstrap's HTTP client calls it and sends no session cookies.- No
rewrites()and no proxy settings innext.config.ts.
Alternatives
- The Next.js rewrite (0065): removed by the user.
- The app's nginx proxying
/apito the API: not chosen;next devhas no nginx.
Consequences
- Back end: CORS must allow each app's origin with credentials (
CORS_ORIGINS), and the refresh cookie path must drop the/apiprefix (AUTH_COOKIE_PATH_PREFIX), or the session never refreshes. - Session cookies belong to the API host. The API and the apps must stay on one site (for example
api.example.comandexample.com), soSameSite=Laxcookies reach the API and its media. - Browser calls pay a CORS preflight. Upload limits and timeouts are the API's own, not Next.js's.
- The client IP reaches the API without an extra proxy hop.