Skip to content

How to resolve content security policy I want to add ADA Compliance from in magento 2.4.3?

I want to whitelist my ADA Compliance script into magento_csp for that i have created CSP_whitelist.xml for resolve following error

Error : Refused to load the script ‘https://acsbapp.com/apps/app/dist/js/app.js’ because it violates the following Content Security Policy directive: “script-src ‘self’ ‘unsafe-inline’ ‘unsafe-eval'”. Note that ‘script-src-elem’ was not explicitly set, so ‘script-src’ is used as a fallback.

I have added following code in config.xml file

<default>
        <csp>
            <policies>
                <storefront>
                    <report_only>0</report_only>
                </storefront>
                <admin>
                    <report_only>0</report_only>
                </admin>
            </policies>
        </csp>
    </default>

In csp_whitelist.xml file i have added following code


<policies>
         <policy id="script-src">
            <values>
               <value id="accessibe" type="host">https://accessibe.com/</value>
                <value id="acsbapp" type="host">acsbapp.com</value>
            </values>
        </policy>
    </policies>

After put above code i am getting following error on site front-end

1 exception(s):
Exception #0 (Exception): Warning: Illegal string offset ‘policy_id’ in /vendor/magento/module-csp/Model/Collector/ConfigCollector.php on line 84

so if anyone know issue then please let me know what is going wrong where am i doing mistake.

Front-end error screen-shot : https://nimb.ws/Jyd1hB

Thanks