23 lines
1.7 KiB
Markdown
23 lines
1.7 KiB
Markdown
# 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) and `NEXT_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_POINT` is the API's public origin (the gateway, or admin-api in the admin app). The client bootstrap's HTTP client calls it directly with `credentials: 'include'`, and the platform's `apiBaseUrl` (media and upload URLs) uses it.
|
|
- `INTERNAL_END_POINT` is 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 in `next.config.ts`.
|
|
|
|
## Alternatives
|
|
- The Next.js rewrite (0065): removed by the user.
|
|
- The app's nginx proxying `/api` to the API: not chosen; `next dev` has no nginx.
|
|
|
|
## Consequences
|
|
- Back end: CORS must allow each app's origin with credentials (`CORS_ORIGINS`), and the refresh cookie path must drop the `/api` prefix (`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.com` and `example.com`), so `SameSite=Lax` cookies 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.
|