CSP Header #442
-
Is there a way to use CSP headers with NextJs on the edge? I use the solution here: vercel/next.js#42330 (comment) it works fine when building/running with next on my local machine. For NextJs the nonce get parsed out of the headers (https://stackoverflow.com/a/76567353/13946940) but this doesn't seam to work by default wenn deployed to cloudflare workers. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @wuifdesign 🙂👋 I tried to also apply your solution, I cloned the repository present in the comment you linked, this is my fork: I've only added a single commit to change the routes to use the edge runtime I've deployed the application here: https://nextjs-csp-report-only.pages.dev/ And it looks to me like the (PS: I also deployed the app on vercel: https://nextjs-csp-report-only-pi.vercel.app/csp and the result seems identical to me) Am I missing something? |
Beta Was this translation helpful? Give feedback.
Hi @wuifdesign 🙂👋
I tried to also apply your solution, I cloned the repository present in the comment you linked, this is my fork:
https://github.com/dario-piotrowicz/nextjs-csp-report-only
I've only added a single commit to change the routes to use the edge runtime
I've deployed the application here: https://nextjs-csp-report-only.pages.dev/
And it looks to me like the
nonce
s are getting generated as expected at https://nextjs-csp-report-only.pages.dev/csp :(PS: I also deployed the app on vercel: https://nextjs-csp-report-only-pi.vercel.app/csp and the result seems identical to me)
Am I missing something?