Skip to content

What it does not protect

PreviewLatch runs inside your server. Anything that does not pass through your server, or that a signed-in person hands on, is outside its reach. Here is the full list.

  1. A CDN in front of your site that caches by URL

    If a cache sits in front of your server and stores responses by address alone, it can hand a page that was fetched by a signed-in person to someone who is not. Off Vercel, the middleware adds CDN-Cache-Control: no-store and Surrogate-Control: no-store to gated responses, which most CDNs respect. Check that yours does, and do not set rules that force caching of HTML or API responses.

  2. Hosts that serve _next/static without running middleware

    Some hosts serve built files straight from storage and never run your middleware for them. On those hosts your JavaScript and CSS are public, even though pages are gated. They should not contain secrets anyway, but they can reveal text, routes and design.

  3. A matcher that excludes paths

    If you add a config.matcher to the proxy file, every path it leaves out is not gated. Do not add one. Use publicPaths for the few things that must be public.

  4. Static export

    A site built with output: "export" has no server, so there is nothing to run the gate. A mode for static sites is not available yet.

  5. Assets or APIs on other domains

    The gate only covers requests to the site it runs in. Images in an outside bucket, a separate API domain, or a headless CMS stay as open as they were.

  6. Deployments made before the middleware was added

    Older preview deployments that were built without the proxy file are still reachable at their own addresses. Delete them, or protect them with your host's own settings.

  7. Someone sharing their password or cookie

    Anyone with a working password or session cookie gets in. Give each person their own password, use one-time or expiring passwords for short visits, and revoke anything that may have been passed on.

  8. The revocation window

    A revoked session keeps working until the site's next recheck: up to 60 seconds by default, or whatever you set between 15 seconds and 15 minutes. If your server cannot reach PreviewLatch, existing sessions keep working for up to the offline grace (24 hours by default) or until they expire. Set offlineGraceSeconds: 0 if you prefer locking people out during an outage.

  9. Forged client addresses on servers reachable directly

    The per-address limit on failed sign ins reads x-forwarded-for or x-real-ip. On Vercel the platform sets these. On a server that visitors can reach directly, they can forge them, which weakens the per-address limit only. The per-site limit still holds. Pass clientIp to read the address your own proxy sets.

  10. Unpatched Next.js

    Next.js versions before 14.2.25 and 15.2.3 have a flaw (CVE-2025-29927) that lets a crafted request skip middleware, and so skip the gate. Use 14.2.25, 15.2.3, or newer.