Solving the Magento 2.3.5-p1 Content Security Policy Issue
Dear Magento store owners,
If you’ve recently upgraded to version 2.3.5-p1 and are now facing a blank frontend with error messages about violated Content Security Policies, don’t panicâwe’re here to help!
Understanding the Issue
After the upgrade, your Magento site may display blank pages with console errors like this:
[Report Only] Refused to load the stylesheet 'http://static.domain.com/pub/static/version1633097154/frontend/Magento/luma/en_US/mage/calendar.css' because it violates the following Content Security Policy directive: "style-src 'self' https: blob: data:".
This happens due to a change in the way Magento handles static content deployment. The new version updates the security policies but doesn’t automatically adjust your existing configuration.
Step-by-Step Solution
1. Check Your Deployment Process
Ensure that you’ve correctly deployed the static and media contents for the new version:
- Run
bin/magento setup:static-content:deployto deploy all static content. - Make sure the
pub/staticfolder contains the updated files.
2. Modify the Security Policies
You can modify the security policies in two ways:
Option A: Via the Admin Panel
- Login to your Magento admin panel (e.g.,
admin.domain.com/admin/. - Navigate to Stores > Settings > Configuration.
- Under General, select Web.
- Scroll down to Security and find the “Security Policies” section.

-
Modify the policies as necessary to match your domain setup:
- For
static.domain.com: Setstyle-srcto'self' http: https: blob: data: - For
media.domain.com: Setimg-srcto'self' http: https:and addhttp: //www.static.domain.com/as an exception.
- For
-
Click Save Config and then run
bin/magento cache:flush.
Option B: Via the .htaccess File
If you can’t modify the admin panel settings, you can manually update the .htaccess file located in the root directory of your Magento installation:
- Open a text editor.
- Add the modified policies to the bottom of the
Environmentsection:
<IfModule mod_headers.c>
<IfModule mod_setenvif.c>
# set environment variable for the actual path
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
# force https redirect if not already forced by other rules
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-XSS-Protection "1; mode=block"
Header always set X-Content-Type-Options "nosniff"
# Content Security Policy (CSP) settings
if (HTTPS != on) {
Header set Content-Security-Policy "style-src 'self' http: https: blob: data:"
Header set X-XSS-Protection "0"
Header set X-Frame-Options "ALLOWALL"
}
</IfModule>
</IfModule>
- Save the file and upload it back to your server.
- Run
bin/magento cache:flushfrom the command line.
Conclusion
Remember, security is a top priority for Magento.
Always ensure you follow Magento’s official upgrade guide to avoid potential issues like this one.
If you still encounter difficulties after trying these steps, or if your site requires additional customizations, don’t hesitate to contact our expert team at Laravel Company.
Stay secure and happy coding!