You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Keshav 2e3940193a Update 'README.md' 4 months ago
README.md Update 'README.md' 4 months ago

README.md

Content security policy (CSP) in webflow

While Webflow manages most aspects of your website's Content Security Policy (CSP), you can still fine-tune it through custom code injection. Here's how you can achieve that with short and clean code examples:

1. Understanding CSP in Webflow:

Webflow implements a default CSP that restricts resources like scripts, styles, and fonts to their CDN and authorized domains. This enhances security by preventing malicious code injection.

2. Customizing the CSP:

You can customize the CSP by injecting custom headers into your Webflow site. This allows you to:

  • Allowlist additional domains for specific resources like fonts or scripts.
  • Define custom directives like script-src or style-src with specific source rules.
  • Enable features like unsafe-inline for inline scripts needed by specific plugins.

3. Short & Clean Code Examples:

Here are some examples of custom CSP directives:

  • Allowlist Google Fonts:
HTML
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' https://fonts.googleapis.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com fonts.gstatic.com;">
  • Allowlist a custom script from your domain:
HTML
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' https://yourdomain.com/customscript.js;">

Also, make sure to read Webflow documentation in detail. Refer to their detailed CSP guide for specific rules and best practices.

Need Help?

Stuck with custom css code? Head over to No-Code Webflow Development Agency.