Security headers
X-Frame-Options controls whether other websites may embed your pages in an iframe. The modern equivalent is the frame-ancestors directive in a Content-Security-Policy.
Not sure whether your site has this problem? Check it in seconds.
If any site can frame yours, an attacker can overlay your page with invisible or disguised elements and trick visitors into clicking things (clickjacking), such as a button that changes a setting while they think they're clicking something harmless.
Check the response headers for X-Frame-Options, or for a Content-Security-Policy containing frame-ancestors. Either one is enough.
Header value
X-Frame-Options: SAMEORIGINNginx
add_header X-Frame-Options "SAMEORIGIN" always;Apache
Header always set X-Frame-Options "SAMEORIGIN"Next.js (next.config.ts)
const nextConfig = {
async headers() {
return [
{
source: "/:path*",
headers: [{ key: "X-Frame-Options", value: "SAMEORIGIN" }],
},
];
},
};
export default nextConfig;CSP alternative
Content-Security-Policy: frame-ancestors 'self'frame-ancestors is the current standard and takes precedence in browsers that support both. Sending both is common and harmless.
Guidance is general. Test header and DNS changes on a staging copy first, and check your hosting provider's documentation for platform-specific steps.