diff --git a/app/api/preview/route.ts b/app/api/preview/route.ts index 9e0b279..1ae7e55 100644 --- a/app/api/preview/route.ts +++ b/app/api/preview/route.ts @@ -21,8 +21,9 @@ export async function GET(request: NextRequest, res: NextResponse) { const slug = request.nextUrl.pathname const ContentID = searchParams.get('ContentID') + const contentID = parseInt(ContentID || "") - console.log("Preview Request", { agilityPreviewKey, slug, ContentID, url: request.nextUrl.toString() }) + console.log("Preview Request", { agilityPreviewKey, slug, contentID, url: request.nextUrl.toString() }) //validate our preview key, also validate the requested page to preview exists @@ -40,8 +41,8 @@ export async function GET(request: NextRequest, res: NextResponse) { let previewUrl = slug; //TODO: these kinds of dynamic links should work by default (even outside of preview) - if (ContentID) { - const dynamicPath = await getDynamicPageURL({ contentID: ContentID, preview: true, slug }); + if (!isNaN(contentID) && contentID > 0) { + const dynamicPath = await getDynamicPageURL({ contentID, preview: true, slug }); if (dynamicPath) { previewUrl = dynamicPath; }