22 lines
2.0 KiB
Markdown
22 lines
2.0 KiB
Markdown
# 0065 One API end point per side
|
|
|
|
Status: Superseded by 0066 · Area: architecture · Date: 2026-10-16 · Decided by: user · Supersedes: 0018
|
|
|
|
## Context
|
|
The server's API address was an env value (`API_INTERNAL_ORIGIN`, `ADMIN_API_INTERNAL_ORIGIN` in the admin app) and the browser's was a constant (`API_PROXY_PATH = '/api'`). The user wants both as env values with the same keys in every app, set in the bootstraps.
|
|
|
|
## Decision
|
|
- Every app's env has `INTERNAL_END_POINT` (server only) and `NEXT_PUBLIC_CLIENT_END_POINT` (public), with the same names in bull, bear and wall-street-plaza.
|
|
- `INTERNAL_END_POINT` is the API's origin from inside the deployment network (the gateway, or admin-api in the admin app). The server bootstrap's HTTP client calls it directly and sends no session cookies.
|
|
- `NEXT_PUBLIC_CLIENT_END_POINT` is a path on the app's own origin (`/api`), never another origin. The client bootstrap's HTTP client and the platform's `apiBaseUrl` (media URLs) use it, and each app's `next.config.ts` rewrites `<path>/:path*` to `INTERNAL_END_POINT`.
|
|
- The gateway still scopes the refresh cookie to `/api/v1/auth` (`AUTH_COOKIE_PATH_PREFIX=/api`) and keeps the apps' origins in `CORS_ORIGINS`.
|
|
|
|
## Alternatives
|
|
- A constant `/api` for the browser (0018): replaced, the user wants both sides set by env.
|
|
- A full URL for the browser end point: not chosen; cross-origin calls bring back CORS and API-host cookies (0018's context). The env lib's `sitePath` rejects an origin.
|
|
|
|
## Consequences
|
|
- `next build` fixes the rewrite, so each environment's build needs both values; `SKIP_ENV_VALIDATION` can't skip them, and a build without them fails.
|
|
- Changing `NEXT_PUBLIC_CLIENT_END_POINT` from `/api` also needs the gateway's `AUTH_COOKIE_PATH_PREFIX` changed, or the refresh cookie never reaches the refresh call.
|
|
- 0018's proxy consequences still hold: API traffic passes through the Next.js server (`API_PROXY_TIMEOUT_MS`), and the client IP comes from the edge's `X-Forwarded-For`.
|