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.
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-storeandSurrogate-Control: no-storeto gated responses, which most CDNs respect. Check that yours does, and do not set rules that force caching of HTML or API responses.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.
A matcher that excludes paths
If you add a
config.matcherto the proxy file, every path it leaves out is not gated. Do not add one. UsepublicPathsfor the few things that must be public.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.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.
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.
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.
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: 0if you prefer locking people out during an outage.Forged client addresses on servers reachable directly
The per-address limit on failed sign ins reads
x-forwarded-fororx-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. PassclientIpto read the address your own proxy sets.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.