Basic Architecture of Sport Web

This commit is contained in:
Nông Đức Huy
2026-08-11 13:37:25 +07:00
commit 8032fff6ac
262 changed files with 20348 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import { createApiClient } from '@sport/api-client';
import { clientEnv, getServerEnv } from './env';
/**
* Two clients, because the two runtimes have different needs:
*
* - `serverApi` runs inside React Server Components and route handlers. In
* Docker it reaches the API container over the internal network, skipping
* the public hostname and TLS entirely.
* - `browserApi` runs in the browser, hits the public API and carries the
* access token.
*
* Both are the same typed client from @sport/api-client. No component anywhere
* calls `fetch` against the API directly.
*/
export function getServerApi() {
return createApiClient({
baseUrl: getServerEnv().API_INTERNAL_URL,
// Server-side requests are anonymous by default. Authenticated server
// fetches pass the token explicitly, per request, once auth lands.
});
}
export const browserApi = createApiClient({
baseUrl: clientEnv.NEXT_PUBLIC_API_URL,
getAccessToken: () => null, // wired to the auth store in the auth milestone
});