<token> should be replaced with the secret token you generated.
<path> should be the path for the page that you want to view. If you want to view /posts/foo, then you should use &slug=/posts/foo.
Your headless CMS might allow you to include a variable in the draft URL so that <path> can be set dynamically based on the CMS’s data like so: &slug=/posts/{entry.fields.slug}
Finally, in the Route Handler:
Check that the secret matches and that the slug parameter exists (if not, the request should fail).
Call draftMode.enable() to set the cookie.
Then redirect the browser to the path specified by slug.
app/api/draft/route.ts // route handler with secret and slug
import { draftMode } from 'next/headers'
import { redirect } from 'next/navigation'
 
export async function GET(request: Request) {
  // Parse query string parameters