Content Security Policy

How ngx-stripe and Stripe.js fit together

Happy to help with either — this note just points you to the fastest answer. ngx-stripe wraps Stripe.js for Angular (DI, Observables, CDN loading, Element hosts). Stripe.js owns Element appearance, payment methods, validation copy, and PCI. For styling, placeholders, installments, and Element options, Stripe’s docs are usually the best first stop; for Angular setup and our components, you’re in the right place. See also FAQs, CSP, and Stripe.js.

Enterprise apps often fail Stripe Elements because the CSP blocks the Stripe.js CDN or Element iframes. ngx-stripe injects https://js.stripe.com/{named-version}/stripe.js (for example endive on the latest line). Allow those hosts explicitly.

Minimal allowlist

Prefer Stripe’s official CSP guidance and adjust to your policy engine. The snippet below is a starting point, not a complete production policy.

Content-Security-Policy:
  default-src 'self';
  script-src 'self' https://js.stripe.com;
  frame-src https://js.stripe.com https://hooks.stripe.com;
  connect-src 'self' https://api.stripe.com;
  img-src 'self' https://*.stripe.com;
  # Only if you enforce Trusted Types on scripts:
  # trusted-types angular angular#unsafe-bypass ngx-stripe;
  # require-trusted-types-for 'script';
  • script-src — Stripe.js from https://js.stripe.com
  • frame-src — Element iframes and 3DS / bank redirects ( js.stripe.com, hooks.stripe.com)
  • connect-src — API calls to https://api.stripe.com

Full reference: Stripe CSP guide.

Trusted Types

Most apps load Stripe.js with a plain CDN string. If your CSP enforces Trusted Types (require-trusted-types-for 'script'), ngx-stripe retries with policy ngx-stripe (Stripe CDN only). Allow that name in CSP, e.g. trusted-types angular angular#unsafe-bypass ngx-stripe, or load Stripe.js yourself before bootstrapping ngx-stripe.