Skip to content

Glossary

Content Security Policy (CSP)

A Content Security Policy is a set of instructions a site sends to the browser, normally in the `Content-Security-Policy` response header, that restricts what the page may load and run, which mainly limits the damage of cross-site scripting. Meadowstack 2.1 sets no headers, because it does not run your server, but its security docs give a policy tried against the kit's production build.

By Bohuslav PoláčekChecked

docs/security.md
default-src 'self';
script-src 'self' 'sha256-<hash of the theme script>';
style-src 'self' 'unsafe-inline';
img-src 'self' data: blob:;
font-src 'self';
connect-src 'self' https://api.your-company.example;
object-src 'self';
base-uri 'self';
form-action 'self';
frame-ancestors 'none'
The policy in docs/security.md; its core ran against the demo's production build with no violations.

Why it matters in a business app

A business app shows text other people typed: a supplier's name, a comment, a file name. If any of that ever reaches the page as markup, a script can run with the person's session. React escapes text and the kit renders Markdown without HTML, so the first line of defence is there; a CSP is the second, deciding where scripts may come from and where data may be sent even if something slips through.

MDN lists two other uses: frame-ancestors against clickjacking, and enforcing HTTPS. It also notes that Content-Security-Policy-Report-Only reports violations without blocking, which is how to try a policy on a live app.

How Meadowstack handles it

docs/security.md explains every line of the policy above by what the kit does:

  • script-src with a hash. The page has one inline script, the theme script that prevents a white flash in dark mode; allow exactly it by its hash, computed from the built page.
  • style-src 'unsafe-inline'. Three dependencies (the toasts, the dialogs' scroll lock, the motion library) add style elements at run time; a style cannot run code, so the script rule stays strict.
  • img-src data: blob: for the tab icon drawn on a canvas and previews of files about to be uploaded; object-src 'self' because FilePreview shows PDFs in an object element.
  • frame-ancestors 'none' works only as a header, not in a meta tag.
  • Never 'unsafe-eval': nothing in the kit needs it.

Setting the header is yours in 2.1: a vercel.json, a _headers file or nginx. Meadowstack 3.0, coming as an update to every licence, ships strict headers with every app.

Common mistakes

  • 'unsafe-inline' for scripts because one inline script needed it. Hash that script instead.
  • The dev server's policy in production. Hot reload needs a looser policy; production does not.
  • connect-src left at 'self' when the api lives elsewhere: every call fails. List the api's origin.
  • Shipping without trying it. Open the app with the console open and use every feature once; each blocked request is logged.

Sources

Questions

Can I set a Content Security Policy in a meta tag?

Yes, with a meta element, but it does not support every feature: frame-ancestors and report-only mode work only as headers. Use the header in production.

Does Meadowstack set a Content Security Policy?

Not in 2.1: the framework does not run your server. The security docs give a policy tried against the kit and explain each line; Meadowstack 3.0 sets strict headers by default.

Why does the policy allow inline styles?

Three of the kit's dependencies add style elements at run time, and blocking them breaks the toasts' layout and the dialogs' scroll lock. Inline styles cannot run code; inline scripts stay blocked.

Two ways

Build it yourself, or have it built

  • Build it yourself

    Build your app on the framework

    Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.

    One payment, lifetime updates

    Get the framework
  • Have it built

    Have us build your app

    Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.

    After launch, Care keeps it improving, from €99 a month.

    from €1,990

    Describe your app