fix(storefront-chat): allow widget iframe embedding via CSP frame-ancestors

Shopify storefronts embed the chat widget cross-origin; Firefox blocks
unless the response allows framing. Set Content-Security-Policy with
frame-ancestors * for /storefront-chat/widget routes.

Made-with: Cursor
This commit is contained in:
talatops 2026-04-02 21:57:26 +05:00
parent 0b384fcc59
commit 8e25dd88e8

View File

@ -1,7 +1,26 @@
import type { NextConfig } from "next"; import type { NextConfig } from "next";
/** Lets Shopify / custom domains embed the public widget in an iframe (Firefox blocks without this). */
const STOREFRONT_WIDGET_CSP = "frame-ancestors *";
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
/* config options here */ /* config options here */
async headers() {
return [
{
source: "/storefront-chat/widget",
headers: [
{ key: "Content-Security-Policy", value: STOREFRONT_WIDGET_CSP },
],
},
{
source: "/storefront-chat/widget/:path*",
headers: [
{ key: "Content-Security-Policy", value: STOREFRONT_WIDGET_CSP },
],
},
];
},
// Keep Prisma + pg as Node externals so Turbopack does not bundle the // Keep Prisma + pg as Node externals so Turbopack does not bundle the
// generated client (fixes "Cannot read properties of undefined (reading 'graph')" // generated client (fixes "Cannot read properties of undefined (reading 'graph')"
// during `next build` in some Docker/Linux environments). // during `next build` in some Docker/Linux environments).