@djangocfg/nextjs 2.1.471 → 2.1.472

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.
@@ -24,6 +24,7 @@ declare function createRouting(config?: Partial<I18nConfig>): {
24
24
  localePrefix?: next_intl_routing.LocalePrefix<string[], "always" | "as-needed" | "never">;
25
25
  domains?: never;
26
26
  localeCookie?: boolean | {
27
+ name?: string;
27
28
  maxAge?: number | undefined;
28
29
  priority?: "low" | "medium" | "high" | undefined;
29
30
  domain?: string | undefined;
@@ -31,7 +32,6 @@ declare function createRouting(config?: Partial<I18nConfig>): {
31
32
  secure?: boolean | undefined;
32
33
  sameSite?: true | false | "lax" | "strict" | "none" | undefined;
33
34
  partitioned?: boolean | undefined;
34
- name?: string;
35
35
  };
36
36
  alternateLinks?: boolean;
37
37
  localeDetection?: boolean;
@@ -46,6 +46,7 @@ declare const routing: {
46
46
  localePrefix?: next_intl_routing.LocalePrefix<string[], "always" | "as-needed" | "never">;
47
47
  domains?: never;
48
48
  localeCookie?: boolean | {
49
+ name?: string;
49
50
  maxAge?: number | undefined;
50
51
  priority?: "low" | "medium" | "high" | undefined;
51
52
  domain?: string | undefined;
@@ -53,7 +54,6 @@ declare const routing: {
53
54
  secure?: boolean | undefined;
54
55
  sameSite?: true | false | "lax" | "strict" | "none" | undefined;
55
56
  partitioned?: boolean | undefined;
56
- name?: string;
57
57
  };
58
58
  alternateLinks?: boolean;
59
59
  localeDetection?: boolean;
package/dist/index.mjs CHANGED
@@ -14,7 +14,7 @@ var require_package = __commonJS({
14
14
  "package.json"(exports, module) {
15
15
  module.exports = {
16
16
  name: "@djangocfg/nextjs",
17
- version: "2.1.471",
17
+ version: "2.1.472",
18
18
  description: "Next.js server utilities: sitemap, health, OG images, contact forms, navigation, config",
19
19
  keywords: [
20
20
  "nextjs",
@@ -1670,38 +1670,57 @@ function createBaseNextConfig(options = {}) {
1670
1670
  ];
1671
1671
  const hasIframeAllowlist = !!options.allowIframeFrom && options.allowIframeFrom.length > 0;
1672
1672
  const frameAncestors = hasIframeAllowlist ? options.allowIframeFrom.includes("*") ? "*" : `'self' ${options.allowIframeFrom.join(" ")}` : "'none'";
1673
+ const cspDisabled = options.csp === false;
1674
+ const cspExtra = typeof options.csp === "object" ? options.csp : void 0;
1673
1675
  const stripeScript = options.stripe ? " https://js.stripe.com" : "";
1674
1676
  const stripeConnect = options.stripe ? " https://api.stripe.com" : "";
1675
1677
  const stripeFrame = options.stripe ? " https://js.stripe.com https://checkout.stripe.com" : "";
1676
- const connectSrc = isDev ? `connect-src 'self' http: https: ws: wss:${stripeConnect}` : `connect-src 'self' https: wss:${stripeConnect}`;
1677
- const imgSrc = isDev ? "img-src 'self' data: blob: http: https:" : "img-src 'self' data: blob: https:";
1678
- const cspDirectives = [
1679
- "default-src 'self'",
1680
- // Next.js requires inline + eval for its runtime/HMR. Tighten to nonces later.
1681
- `script-src 'self' 'unsafe-inline' 'unsafe-eval'${stripeScript}`,
1682
- "style-src 'self' 'unsafe-inline'",
1683
- imgSrc,
1684
- "font-src 'self' data:",
1685
- // API/websocket calls go cross-origin to Django/Centrifugo.
1686
- connectSrc,
1687
- // Stripe Elements/Checkout mount iframes; add their hosts when enabled.
1688
- `frame-src 'self'${stripeFrame}`,
1689
- "object-src 'none'",
1690
- "base-uri 'self'",
1691
- "form-action 'self'",
1692
- `frame-ancestors ${frameAncestors}`
1693
- ];
1694
- headers.push({
1695
- source: "/:path*",
1696
- headers: [
1697
- { key: "X-Content-Type-Options", value: "nosniff" },
1698
- { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
1699
- { key: "Content-Security-Policy", value: cspDirectives.join("; ") },
1700
- // X-Frame-Options for older browsers. Omitted when a wildcard iframe
1701
- // allowlist is set (browsers then rely on CSP frame-ancestors).
1702
- ...hasIframeAllowlist && options.allowIframeFrom.includes("*") ? [] : [{ key: "X-Frame-Options", value: hasIframeAllowlist ? "SAMEORIGIN" : "DENY" }]
1703
- ]
1704
- });
1678
+ const extraScript = cspExtra?.scriptSrc?.length ? " " + cspExtra.scriptSrc.join(" ") : "";
1679
+ const extraConnect = cspExtra?.connectSrc?.length ? " " + cspExtra.connectSrc.join(" ") : "";
1680
+ const extraFrame = cspExtra?.frameSrc?.length ? " " + cspExtra.frameSrc.join(" ") : "";
1681
+ const extraImg = cspExtra?.imgSrc?.length ? " " + cspExtra.imgSrc.join(" ") : "";
1682
+ const extraFont = cspExtra?.fontSrc?.length ? " " + cspExtra.fontSrc.join(" ") : "";
1683
+ const connectSrc = isDev ? `connect-src 'self' http: https: ws: wss:${stripeConnect}${extraConnect}` : `connect-src 'self' https: wss:${stripeConnect}${extraConnect}`;
1684
+ const imgSrc = isDev ? `img-src 'self' data: blob: http: https:${extraImg}` : `img-src 'self' data: blob: https:${extraImg}`;
1685
+ if (!cspDisabled) {
1686
+ const cspDirectives = [
1687
+ "default-src 'self'",
1688
+ // Next.js requires inline + eval for its runtime/HMR. Tighten to nonces later.
1689
+ `script-src 'self' 'unsafe-inline' 'unsafe-eval'${stripeScript}${extraScript}`,
1690
+ "style-src 'self' 'unsafe-inline'",
1691
+ imgSrc,
1692
+ `font-src 'self' data:${extraFont}`,
1693
+ // API/websocket calls go cross-origin to Django/Centrifugo.
1694
+ connectSrc,
1695
+ // Stripe Elements/Checkout and any app-declared trusted origins
1696
+ // (options.csp.frameSrc) mount iframes; add their hosts when enabled.
1697
+ `frame-src 'self'${stripeFrame}${extraFrame}`,
1698
+ "object-src 'none'",
1699
+ "base-uri 'self'",
1700
+ "form-action 'self'",
1701
+ `frame-ancestors ${frameAncestors}`
1702
+ ];
1703
+ headers.push({
1704
+ source: "/:path*",
1705
+ headers: [
1706
+ { key: "X-Content-Type-Options", value: "nosniff" },
1707
+ { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
1708
+ { key: "Content-Security-Policy", value: cspDirectives.join("; ") },
1709
+ // X-Frame-Options for older browsers. Omitted when a wildcard iframe
1710
+ // allowlist is set (browsers then rely on CSP frame-ancestors).
1711
+ ...hasIframeAllowlist && options.allowIframeFrom.includes("*") ? [] : [{ key: "X-Frame-Options", value: hasIframeAllowlist ? "SAMEORIGIN" : "DENY" }]
1712
+ ]
1713
+ });
1714
+ } else {
1715
+ headers.push({
1716
+ source: "/:path*",
1717
+ headers: [
1718
+ { key: "X-Content-Type-Options", value: "nosniff" },
1719
+ { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
1720
+ ...hasIframeAllowlist && options.allowIframeFrom.includes("*") ? [] : [{ key: "X-Frame-Options", value: hasIframeAllowlist ? "SAMEORIGIN" : "DENY" }]
1721
+ ]
1722
+ });
1723
+ }
1705
1724
  const userHeaders = options.headers ? await options.headers() : [];
1706
1725
  return [...headers, ...userHeaders];
1707
1726
  },