Skip to main content
Headless CMS previews: Keep drafts out of public routes
Platform SEOIntermediate

Headless CMS previews: Keep drafts out of public routes

A preview parameter is not access control. Check CMS permissions, preview entry points, public responses and caching separately to keep unpublished content protected.

Matthias RamahiMatthias Ramahi
8 min readNovember 6, 2026Legacy score: 95/100Updated Nov 17, 2026

An article is marked as a draft in the CMS. Editors can open it through a preview link. Whether unauthorized visitors can retrieve the same text depends on the application. A CMS status field cannot establish that by itself.

A headless CMS separates content management from website delivery. Preview connects the two. CMS read permissions, server-side data requests, preview cookies and public routes may all participate. A defensible acceptance check needs the actual response.

This guide provides a controlled test matrix. All example addresses and content are fictional. It does not report a test of Crawl Foundry's production installation or a customer website. The intended evidence is specific: authorized people can work while unauthorized requests cannot retrieve unpublished content.

Begin with a small route map

Identify the preview entry point, destination page and public article address. They may use different paths or the same route with different session states. Include the API from which the browser or server obtains content.

A fictional setup might use /api/preview as the entry, /preview/article-42 as the destination and /blog/article-42 as the eventual public address. Another application might use a cookie to decide which version /blog/article-42 returns. Each model requires its own checks. A path's name does not establish protection.

Record languages, alternative hosts and required media files too. A protected German preview path says nothing about an English variant. An unpublished article may use images or downloads whose own URLs follow different rules.

Separate access, crawling and indexing

Access control decides whether a request may receive the draft. A robots.txt file addresses crawlers instead. It is not a login mechanism and cannot stop an ordinary HTTP client from requesting the same URL.

Google's robots.txt introduction explains that a blocked URL may still appear in results when other pages link to it. An address that is hard to guess does not establish that the server checks permission either.

Noindex controls inclusion in search engines that support it. It does not stop a person who knows the URL from downloading its contents. Google's documentation requires the crawler to retrieve the instruction. A simultaneous robots block can prevent that.

For confidential drafts, this is not a reason to expose the content to Google. First ensure unauthorized requests cannot retrieve it. An additional indexing instruction on an allowed preview response may be useful, but it cannot replace the permission check. Inspect both the HTML meta element and any X-Robots-Tag header.

Follow CMS permissions through to website output

The Directus Live Preview documentation describes a configurable preview URL. The frontend must handle the request and load the intended version. When previewing versions, it receives the version key and must actually use it in the content request.

A flag such as preview=true or version=draft therefore initially identifies the requested representation. Whether the requester may view it is another decision. An arbitrarily supplied parameter must not substitute for that decision.

Trace the data path. Which identity requests the CMS? Which records and fields may it read? Does the frontend then pass any of those data to public visitors? Directus describes its rules in the access-control reference. Inspect the actual policies and filters. A status name your team chose does not automatically acquire the intended public-access meaning.

A server can use its own read permissions to obtain data unavailable to an anonymous CMS client. A rejected direct API request therefore does not establish that the frontend route is protected too. Test both paths with the appropriate access scope.

Check the effective combination of permissions as well. Directus policies can expand access additively. A restrictive rule in one policy is insufficient evidence when another active policy grants broader access to the same content. The complete permission set of the identity actually used matters.

A negative test makes that boundary concrete. In a fictional collection, the public identity may read only records with the intended publication status. Test both an allowed published record and the separate draft. The two cases belong together: a broken request returning nothing at all would not constitute a working publication path.

Do not blindly apply the example status filter to your schema. Language version, publication time and other approval fields may form part of the real rule. Record the precise conditions defining your public version. A later schema change can then identify which tests require updating.

Protect the preview entry point separately

The Next.js Draft Mode guide makes an important distinction: a handler enabling Draft Mode without a check starts out public. Its example consequently validates a shared secret and requested content before enabling the mode.

Draft Mode sets a cookie for subsequent requests. Switching it on is not equivalent to a complete user- and content-permission model. Define who may receive preview access and which content that access covers. An intentionally issued sharing link can form part of the model; calling a URL “Preview” cannot.

Do not put a long-lived Directus static token in that URL. Directus warns that query-string authentication may be exposed or logged; OWASP’s query-string information exposure guidance notes that HTTPS does not prevent sensitive query values from appearing in browser history, referrers, web logs, or shared systems. If a tokenized hand-off is unavoidable, give it only the access it needs, redact the URL from logs, and exchange it for a session before redirecting to a clean path. Next.js’s example redirects to the verified post path, which removes the secret from the destination URL, but the initial request may still be recorded. A preview link is an entry mechanism, not proof that a draft remains private after the link is copied.

Check the destination after activation as well. The Next.js guide redirects to the path obtained from verified content instead of accepting an arbitrary redirect parameter. Adapt that approach to your application. Do not copy an activation handler in isolation from an introductory example.

Preserve an anonymous GET as the baseline

In an appropriate test environment, create an unpublished test article containing a distinctive, non-confidential marker. The example uses DRAFT-CHECK-42. Keep real business secrets and production access tokens out of the test file.

These requests supply no login and save the headers and complete body separately:

bashcurl -q --compressed -sS -D preview.headers -o preview.html 'https://example.com/preview/article-42'
curl -q --compressed -sS -D public.headers -o public.html 'https://example.com/blog/article-42?preview=true&version=draft'

On Windows, use curl.exe where necessary. The curl manual's `-q` option suppresses the default configuration file when it is curl's first option. The commands do not automatically follow redirects. If the response points to a login, preserve that step and check the destination separately. A final login page returning 200 is different from a draft delivered with 200.

Read the status, headers and body together. Look for the marker inside embedded data as well as visible text. A “Please sign in” overlay does not protect a draft already included in the response. HEAD alone cannot provide this evidence.

A hypothetical acceptance matrix

The following plan has not been run against a real installation. It illustrates cases a team can document for its test article. Intended responses depend on the access model chosen deliberately.

Test caseOutcome to verifyWhat it does not establish
Request entry point and destination directly without preview accessNo draft in the body or subsequently loaded dataOther hosts, languages and files may differ
Add parameters without a valid grantParameters alone do not confer draft permissionsThe genuine activation flow must work separately
Open an authorized previewCorrect version visible to the permitted personPublic requests remain untested
Exit preview and request againIntended public or denied stateExiting the mode does not automatically revoke every access route
Request from a fresh session afterwardsNo draft reused from a shared cache responseOther cache layers may require additional evidence

For interactive applications, inspect subsequently loaded browser responses too. An initial HTML response without article text can still be followed by a data request that supplies it. Document the same access states and the actual URL requested.

The Draft Mode reference distinguishes enabling, checking and disabling. disable() ends the mode through the cookie. Whether a previously issued sharing link or another authenticated session remains valid depends on your additional access logic.

Separate preview and public cache responses

With server-side rendering, the generated response need not be identical for every recipient. Request order therefore matters: open an authorized preview first, then request the public address without that state. This tests whether a previous draft response is reused publicly.

HTTP caching specification RFC 9111 distinguishes private, no-cache and no-store. Broadly, unqualified private prohibits storage in shared caches. no-cache requires successful validation before reuse. no-store prohibits caches from storing the relevant response. None of these directives authenticates the visitor.

Record actual response headers and your cache rules. A header in application code does not establish that an upstream layer receives and honors it unchanged. A new rule also does not automatically remove every copy previously delivered or stored.

Current Next.js documentation describes cache bypass and private response headers for Draft Mode. Still verify the deployed build and full delivery path. Framework behavior does not test your proxy, CDN and data-source configuration.

Check public discovery paths

Then examine listings, feeds, search features and the XML sitemap. They should expose the intended publication inventory. An unlinked preview is not automatically protected, however. Removing a link cannot replace access control.

For internal linking, include preview parameters in copied editorial links in the review. Publish only the intended public address. Look for preview hosts or draft identifiers in the relevant outputs you control. One missing sitemap entry does not establish complete separation.

If content has already been delivered publicly, correct access first and inspect affected copies. Removing visible search results is a further task. Do not expose confidential content again merely so a crawler can read an instruction added afterwards.

Connect publication approval with technical acceptance

At publication, recheck the public version without preview state. It needs the intended content and indexing rules. The SEO migration checklist helps with larger changes; add the separate access and session cases for drafts.

Use Crawl Foundry's Site Audit to place the public URL inventory into your technical workflow. Run the private preview test with specifically defined permissions and evidence. A public crawl does not replace it.

Our workflow for handling technical audit findings helps prepare the handoff. Record route, release, person or session state, expected version and actual response. Acceptance then establishes the paths tested. It does not claim complete security across every CMS, file and publishing feature.

Build a keyword database you own

Import and organize keywords, audit technical issues with evidence, and export everything at any time.

Start Free
Matthias Ramahi

Matthias Ramahi

Founder, Crawl Foundry

SEOKeyword ResearchTechnical SEO

Matthias Ramahi is the founder of Crawl Foundry and leads the product, its data sources, and its editorial standards. Crawl Foundry is his central software and SEO project.

Prefer Crawl Foundry on Google

Add crawlfoundry.com as a preferred source in your Google account and our articles will appear higher up on Google. Optional, and you can undo it at any time.

Set as preferred source

You Might Also Like

Search this website

Find product information, FAQ and documentation with links to the original pages.