We have magento site with enabled CF rocket loader feature. After deploy CSP config we have an issue with requirejs - require is not defined. It’s related to the rocket loader, if we disable it, everything works fine. I want to mention that we’ve added to the HTTP header ajax.cloudflare.com as written in CF docs Content Security Policies (CSPs) and Cloudflare
What steps have you taken to resolve the issue?
Remove csp or disable rocket loader
What are the steps to reproduce the issue?
Magento site with turn on csp headers and enabled rocket loader
If you know the script that is getting issues with Rocket Loader enabled, then you could exclude this specific script from running through Rocket Loader by adding the attribute data-cfasync="false" to the script tag element. For more information on this I recommend reviewing this document:
Is there any other way to resolve the issue? RequireJS is a JavaScript file and module loader. I think it’s a bad idea to exclude this file from rocket loader and it can cause performance.