Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions console-ui/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,48 @@
import type { NextConfig } from "next";

// Content-Security-Policy directives.
// - 'unsafe-inline' for style-src: required by Next.js for injected styles.
// - 'unsafe-inline' + 'unsafe-eval' for script-src: required by Privy SDK
// and Next.js dev mode. Tighten to nonce-based CSP when feasible.
// - connect-src: coordinator API, Privy auth, Google Analytics, Stripe.
// - frame-src: Privy auth iframes, Stripe Checkout iframes.
const cspDirectives = [
"default-src 'self'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.googletagmanager.com https://js.stripe.com",
"style-src 'self' 'unsafe-inline'",
"img-src 'self' data: blob: https:",
"font-src 'self' data:",
"connect-src 'self' https://api.darkbloom.dev https://*.privy.io wss://*.privy.io https://www.google-analytics.com https://api.stripe.com",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Allow non-default coordinator origins in connect-src

The new CSP hardcodes connect-src to https://api.darkbloom.dev, but the UI intentionally supports alternate coordinator endpoints (for example via localStorage.getItem("darkbloom_coordinator_url") and NEXT_PUBLIC_COORDINATOR_URL in provider pages) and then issues browser-side fetch calls to that dynamic origin. With this header, any non-default deployment/dev environment will have those requests blocked by CSP, breaking flows like provider dashboard and earnings outside api.darkbloom.dev.

Useful? React with 👍 / 👎.

"frame-src https://auth.privy.io https://js.stripe.com",
"frame-ancestors 'none'",
"base-uri 'self'",
"form-action 'self'",
].join("; ");

const securityHeaders = [
{ key: "Content-Security-Policy", value: cspDirectives },
{ key: "X-Frame-Options", value: "DENY" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{ key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains; preload" },
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" },
];

const nextConfig: NextConfig = {
typescript: {
// @noble/curves >=1.9 ships raw .ts files with .ts import extensions,
// which fails Next.js type-checking even with skipLibCheck: true.
// This is a known upstream issue in viem's dependency tree.
ignoreBuildErrors: true,
},
async headers() {
return [
{
source: "/(.*)",
headers: securityHeaders,
},
];
},
};

export default nextConfig;
Loading