Magento CSP Rocket loader issue

What is the name of the domain?

What is the error message?

require is not defined

What is the issue you’re encountering

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

Screenshot of the error

Hey there,

Sorry to hear about the issue you are having.

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:

Hi Micky

Thank you for your response

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.

This topic was automatically closed after 15 days. New replies are no longer allowed.