silverwolf-x's picture
download
raw
695 Bytes
// route handler with secret and slug
import { draftMode } from 'next/headers'
import { redirect } from 'next/navigation'
// Preview URL: localhost:3000/api/draft?secret=secret-token&slug=preview-page
export async function GET(request: Request) {
// Parse query string parameters
const { searchParams } = new URL(request.url)
const secret = searchParams.get('secret')
const slug = searchParams.get('slug')
// Check the secret and next parameters
if (secret !== 'secret-token' || !slug) {
return new Response('Invalid token', { status: 401 })
}
// Enable Draft Mode by setting the cookie
;(await draftMode()).enable()
// Redirect to the path
redirect(`/${slug}`)
}

Xet Storage Details

Size:
695 Bytes
·
Xet hash:
7d68fb0011c818a306f875fec55f8bf8c8b653dae76422e0437847ae307a95a1

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.