Stop other sites from framing your pages on Netlify
Why it matters
Without frame-ancestors or X-Frame-Options any site can load your pages in an invisible frame and trick visitors into clicking buttons they cannot see. One header tells browsers which sites, if any, may frame them.
The fix
- Add the lines below to _headers in the publish directory (or [[headers]] in netlify.toml) and redeploy. If you already set a Content-Security-Policy there, add frame-ancestors 'self' to it instead of a second line.
- _headers rules do not apply to Netlify Functions, Edge Functions or proxied responses; those must send the headers themselves.
_headers
/* X-Frame-Options: SAMEORIGIN Content-Security-Policy: frame-ancestors 'self'
Related
Scan your domain to see whether this applies to you.