styled-jsx icon indicating copy to clipboard operation
styled-jsx copied to clipboard

Adding Content Security Policy with Next.js + styled-jsx

Open KarthikeyanRanasthala opened this issue 5 years ago • 4 comments

Do you want to request a feature or report a bug?

Yes, Improve documentation. Please add relevant details/steps on adding nonce for Content Security Policy with styled-jsx + next.js As next.js handles styled-jsx internally, the current mentioned method in the doc is not applicable. This is a major concern as all the next.js apps using styled-jsx have to add 'unsafe-inline' in the CSP. I would request the maintainers to take up this on priority.

KarthikeyanRanasthala avatar Jul 25 '20 12:07 KarthikeyanRanasthala

Any news regarding this issue? @KarthikeyanRanasthala

xereda avatar Mar 27 '24 19:03 xereda

I contributed an example to Next.js repo many years ago. But its no longer available.

You can look into https://github.com/vercel/next.js/pull/23021 and https://github.com/vercel/next.js/tree/canary/examples/with-strict-csp to get an idea.

TBH, I haven't tried it out in app router, so lemme know how it goes.

KarthikeyanRanasthala avatar Mar 28 '24 00:03 KarthikeyanRanasthala

I updated to version 14, but I still use Page Router. Where can I apply "registry.styles({ nonce })"? In my project I use Next.js + styled-jsx. And it is precisely in the styled-jsx styles that the "nonce" is not being applied in the DOM.

xereda avatar Mar 28 '24 12:03 xereda

I updated to version 14, but I still use Page Router. Where can I apply "registry.styles({ nonce })"? In my project, I use Next.js + styled-jsx. And it is precisely in the styled-jsx styles that the "nonce" is not being applied in the DOM.

I am also trying to add the nonce to the style tag, which is dynamically generated from styledjsx, Do you have any solution for for this? @xereda

ganesham019 avatar Feb 18 '25 10:02 ganesham019