@djangocfg/api 2.1.360 → 2.1.361

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -79,7 +79,11 @@ function detectLocale(): string | null {
79
79
  return null;
80
80
  }
81
81
 
82
- /** Default baseUrl from `NEXT_PUBLIC_API_URL` (empty for static builds). */
82
+ /** Default baseUrl from `NEXT_PUBLIC_API_URL`.
83
+ *
84
+ * Both browser and server use NEXT_PUBLIC_API_URL — requests go
85
+ * directly to Django without Next.js proxy.
86
+ */
83
87
  function defaultBaseUrl(): string {
84
88
  try {
85
89
  if (typeof process !== 'undefined' && process.env) {
@@ -90,8 +94,15 @@ function defaultBaseUrl(): string {
90
94
  return '';
91
95
  }
92
96
 
93
- /** Default API key fallback from `NEXT_PUBLIC_API_KEY`. */
97
+ /** Default API key fallback from `NEXT_PUBLIC_API_KEY`.
98
+ *
99
+ * In the browser: returns null — requests go through the Next.js rewrite
100
+ * and the key is injected server-side (never exposed in the bundle).
101
+ * On the server: reads NEXT_PUBLIC_API_KEY as a fallback for SSR calls
102
+ * that bypass the rewrite (e.g. server components calling Django directly).
103
+ */
94
104
  function defaultApiKey(): string | null {
105
+ if (isBrowser) return null;
95
106
  try {
96
107
  if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_API_KEY) {
97
108
  return process.env.NEXT_PUBLIC_API_KEY;