Next.js: Content Security Policy blocks application scripts
The browser shows Refused to execute inline script and part of the interaction does not work after sharpening CSP. Next.js may need a proper nonce or hash configuration for scripts depending on the rendering method.
How to identify the source of the problem
Check the Content-Security-Policy header and accurate message with the name of the blocked directive. Determine whether the problem concerns your own script, framework or external analytical integration.
Compare the message from the console with the result of the production compilation and the condition after the page has been refreshed.
Repair steps
Configure nonce or hash according to Next.js rendering model and transfer it to the necessary scripts. Eliminate unnecessary inline scripts and limit trusted sources while maintaining tests on static and dynamic pages.
How to Test Solution
Interactions work, and CSP continues to block deliberately unauthorized scripts and unnecessary domains.
Security and restrictions
Do not set unsafe-inline globally just to remove console messages.