1

after upgrade my store to Magento Version 2.4.7 , all other functionalities are working fine, but my checkout display blank only with console errors like this : https://prnt.sc/KEgzFbAg213X

Like this : Refused to execute inline script because it violates the following Content Security Policy directive: "script-src assets.adobedtm.com *.adobe.com www.googleadservices.com www.google-analytics.com googleads.g.doubleclick.net analytics.google.com

I think is it related to Magento_Csp module, since it has been enabled compulsory in 2.4.7 so.

can anyone help me about this ?

3
  • Did my answer help you solve the issue? Commented May 14, 2024 at 5:31
  • not @VivekKumar Commented May 14, 2024 at 5:33
  • try this solution : magento.stackexchange.com/a/373482/95447 Commented May 22, 2024 at 10:22

2 Answers 2

2

In your custom module, create a config.xml file under etc folder, paste the provided code into that file, and then run the following command:

php bin/magento cache:flush

<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <csp> <mode> <storefront_checkout_index_index> <report_only>1</report_only> </storefront_checkout_index_index> </mode> </csp> </default> </config> 
0

Currently it seems like the Content Security Policy mode in your store is set to block the urls violating content security policy. There isn't as such any setting in admin which you can use to set it back to "report only", but you can do so using database.

Run following query on your database.

update core_config_data set value = 1 where path = 'csp/mode/storefront/report_only'; 

Also, going forward if you want to keep a CSP whitelist, you can follow corresponding guide on devdocs here

You just have to create csp_whitelist.xml mentioning the domains you want to allow and which policies you want to allow for that specific domain. The list of policies is already mentioned on the document.

2
  • Unfortunately this does not fix the issue. Commented May 17, 2024 at 7:51
  • what was the result for the query? Commented May 17, 2024 at 9:45

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.