@djangocfg/nextjs 2.1.472 → 2.1.474

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/nextjs",
3
- "version": "2.1.472",
3
+ "version": "2.1.474",
4
4
  "description": "Next.js server utilities: sitemap, health, OG images, contact forms, navigation, config",
5
5
  "keywords": [
6
6
  "nextjs",
@@ -144,9 +144,9 @@
144
144
  "ai-docs": "tsx src/ai/cli.ts"
145
145
  },
146
146
  "peerDependencies": {
147
- "@djangocfg/devtools": "^2.1.472",
148
- "@djangocfg/i18n": "^2.1.472",
149
- "@djangocfg/ui-core": "^2.1.472",
147
+ "@djangocfg/devtools": "^2.1.474",
148
+ "@djangocfg/i18n": "^2.1.474",
149
+ "@djangocfg/ui-core": "^2.1.474",
150
150
  "next": "^16.2.2"
151
151
  },
152
152
  "peerDependenciesMeta": {
@@ -168,11 +168,11 @@
168
168
  "serwist": "^9.5.11"
169
169
  },
170
170
  "devDependencies": {
171
- "@djangocfg/devtools": "^2.1.472",
172
- "@djangocfg/i18n": "^2.1.472",
173
- "@djangocfg/layouts": "^2.1.472",
174
- "@djangocfg/typescript-config": "^2.1.472",
175
- "@djangocfg/ui-core": "^2.1.472",
171
+ "@djangocfg/devtools": "^2.1.474",
172
+ "@djangocfg/i18n": "^2.1.474",
173
+ "@djangocfg/layouts": "^2.1.474",
174
+ "@djangocfg/typescript-config": "^2.1.474",
175
+ "@djangocfg/ui-core": "^2.1.474",
176
176
  "@types/node": "^25.9.5",
177
177
  "@types/react": "19.2.15",
178
178
  "@types/react-dom": "19.2.3",
@@ -329,10 +329,33 @@ export function createBaseNextConfig(
329
329
  return [...headers, ...userHeaders];
330
330
  },
331
331
 
332
- // Rewrites (user-provided only)
333
- ...(options.rewrites && {
334
- rewrites: options.rewrites,
335
- }),
332
+ // Rewrites — first-party analytics ingest proxy, then user rewrites.
333
+ //
334
+ // @djangocfg/analytics POSTs to a RELATIVE /cfg/analytics/collect/ so the beacon
335
+ // stays same-origin (sendBeacon is unreliable cross-origin). On a split-domain
336
+ // deploy (Next on one host, Django on `apiUrl`) that same-origin path has no
337
+ // route here, so every beacon 404s and nothing is ingested — unless we proxy it.
338
+ // Same-domain and static builds keep apiUrl empty and need no proxy.
339
+ ...(((apiUrl && !isStaticBuild) || options.rewrites)
340
+ ? {
341
+ async rewrites() {
342
+ const analyticsProxy =
343
+ apiUrl && !isStaticBuild
344
+ ? [{ source: '/cfg/analytics/:path*', destination: `${apiUrl}/cfg/analytics/:path*` }]
345
+ : [];
346
+ const user = options.rewrites ? await options.rewrites() : [];
347
+ // Ingest must resolve before any page/filesystem route can shadow it.
348
+ if (Array.isArray(user)) {
349
+ return { beforeFiles: analyticsProxy, afterFiles: user, fallback: [] };
350
+ }
351
+ return {
352
+ beforeFiles: [...analyticsProxy, ...(user?.beforeFiles ?? [])],
353
+ afterFiles: user?.afterFiles ?? [],
354
+ fallback: user?.fallback ?? [],
355
+ };
356
+ },
357
+ }
358
+ : {}),
336
359
 
337
360
  // Redirects for URL normalization
338
361
  // Fixes "Failed to construct 'URL': Invalid URL" error with double slashes
@@ -453,6 +476,7 @@ export function createBaseNextConfig(
453
476
  allowIframeFrom,
454
477
  dpop,
455
478
  stripe,
479
+ csp,
456
480
  ...nextConfigOptions
457
481
  } = options;
458
482