Fix guides · Security

How to stop other sites embedding your pages (clickjacking protection)

Without frame protection, any site can load your pages invisibly inside its own and trick visitors into clicking. One header fixes it. Steps for Shopify, WordPress, Webflow, Wix, Squarespace and Next.js.

Time to fix
5–10 minutes
Skill needed
Copy and paste
Who notices
Logged-in visitors and customers

Why it matters

In a clickjacking attack, another site loads your page in an invisible frame and places its own buttons over yours. A visitor thinks they're clicking "Play" and actually clicks "Delete account" or "Confirm" on your site.

Telling browsers that only your own site may frame your pages shuts this down.

“Preventing the browser from loading the page in frame using the X-Frame-Options or Content Security Policy (frame-ancestors) HTTP headers.”

OWASP: Clickjacking Defense Cheat Sheet, the first defense it lists

Before you start

  • Either header works: X-Frame-Options: SAMEORIGIN (shown below, supported everywhere) or a Content-Security-Policy with frame-ancestors 'self'. If you're adding a CSP anyway, frame-ancestors covers this too.
  • If another site of yours needs to embed your pages (a partner portal, an app), list it in frame-ancestors instead: frame-ancestors 'self' https://partner.example.com.

Fix it on your platform

Shopify Managed by the platform

  1. Shopify runs the servers for your store and doesn't let stores on its standard plans add or change response headers, so there's nothing to edit in your theme.
  2. If this check matters to you (for example, for a security questionnaire), ask Shopify support about X-Frame-Options for your store. Stores on Shopify Plus or a headless setup (Hydrogen) can set their own headers.

WordPress

  1. Where you add the header depends on your hosting, not WordPress itself. First check your host's dashboard: many managed WordPress hosts have a security-headers setting.
  2. On Apache hosting, add the line below to the .htaccess file in your site's root folder (back the file up first). On Nginx, add it to your site's server block, or ask your host to.
  3. If your site runs through Cloudflare with the orange-cloud proxy on, you can add the header there instead, with a Response Header Transform Rule.
.htaccess (Apache)
Header always set X-Frame-Options "SAMEORIGIN"
Nginx
add_header X-Frame-Options "SAMEORIGIN" always;

Webflow Managed by the platform

  1. Webflow only allows custom security headers on Enterprise plans. On other plans, this header can't be added.
  2. On Enterprise, add it in Site settings → Publishing → Custom Headers.

Wix Managed by the platform

  1. Wix doesn't offer a setting for custom response headers, so this can't be added from the Wix Editor.
  2. If you need it for compliance, contact Wix support and ask how they handle this header on your domain.

Squarespace Managed by the platform

  1. Squarespace has no setting for custom response headers, and code injection adds code to your pages, not headers.
  2. If you need it for compliance, contact Squarespace support and ask how they handle this header on your domain.

Next.js

  1. Add the header for every route in next.config.ts using headers().
  2. If you host on Vercel or Netlify, you can set it in vercel.json or netlify.toml instead; use one place, not both.
next.config.ts
const nextConfig = {
  async headers() {
    return [
      {
        source: "/:path*",
        headers: [{ key: "X-Frame-Options", value: "SAMEORIGIN" }],
      },
    ];
  },
};

export default nextConfig;

Any other site

  1. Add the header where your site is served from: your web server, hosting control panel or CDN. Pick the example that matches your setup.
  2. Cloudflare (proxied, orange cloud): add it with a Response Header Transform Rule.
Netlify _headers
/*
  X-Frame-Options: SAMEORIGIN
.htaccess (Apache)
Header always set X-Frame-Options "SAMEORIGIN"
Nginx
add_header X-Frame-Options "SAMEORIGIN" always;

Check that it's fixed

  • Re-run your StudioLNC audit: the "Page can be embedded by other sites" issue should be gone.

Find every issue like this on your site

Free audit of performance, accessibility, SEO and security, with fixes for your platform.