-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Summary
Description
Hi MUI X team 👋
We’re on Next.js App Router and use AppRouterCacheProvider with a strict CSP. Other MUI components respect the nonce, but @mui/x-charts-pro export gets blocked by CSP.
CSP (simplified):
style-src-elem 'self' 'nonce-${nonce};
style-src-attr 'unsafe-inline';
Provider:
// layout.tsx
import { AppRouterCacheProvider } from "@mui/material-nextjs/v15-appRouter";
<AppRouterCacheProvider options={{ enableCssLayer: true, nonce }}>
</AppRouterCacheProvider>
Environment
- @mui/x-charts-pro: 8.14.0
- @mui/x-charts: 8.14.0
- @mui/material: 7.1.1
- @mui/material-nextjs: 7.1.1
- @emotion/cache: 11.14.0
- "react": "19.1.1"
- "next": "15.4.7"
Next.js App Router (Chrome/Edge latest)
Console excerpt
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src-elem 'self' 'nonce-…'"
Examples
For example, similar to how the DataGrid component provides a nonce prop (docs here
), it would be helpful if @mui/x-charts-pro could also accept a nonce—either as a prop or automatically injected through AppRouterCacheProvider—so that any <style> tags generated during the export process include the proper nonce for CSP compliance.
Observed: Clicking export (image/PDF) triggers a CSP violation for a <style> (or inline style) created during export. Other MUI components (Dialogs/Popovers/etc.) work under the same CSP.
Expected
Export should inherit or allow passing a nonce so any dynamically created <style> elements (and, if applicable, inline styles) comply with CSP.
Minimal repro idea
A Next.js App Router page rendering with the toolbar export enabled + CSP headers above. I can provide a sandbox or repo if needed.
Thanks for looking into nonce support for charts export 🙏
Search keywords: chart, export, nonce