cannot retrieve url params in route.ts in App router
Unanswered
Sloth bear posted this in #help-forum
Sloth bearOP
I am trying to create a api route
My file is present in app/api/preview/route,ts
when i try to retrieve the url params within GET i get this error
error StaticGenBailoutError: Page with
So i tried exporting as force-dynamic as mentioned in https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
export const dynamic = 'force-dynamic';
But then i receive another error -
Error: export const dynamic = "force-dynamic" on page "/api/preview" cannot be used with "output: export". See more info here: https://nextjs.org/docs/advanced-features/static-html-export
I want to have an api route inspite of exporting my application as static pages to be used for preview in my CMS system. This was possible in the previous versions of nextJS since we used to run npm run export rather than have output: 'export' in next.config.js
My file is present in app/api/preview/route,ts
when i try to retrieve the url params within GET i get this error
error StaticGenBailoutError: Page with
dynamic = "error" couldn't be rendered statically because it used request.url.So i tried exporting as force-dynamic as mentioned in https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
export const dynamic = 'force-dynamic';
But then i receive another error -
Error: export const dynamic = "force-dynamic" on page "/api/preview" cannot be used with "output: export". See more info here: https://nextjs.org/docs/advanced-features/static-html-export
I want to have an api route inspite of exporting my application as static pages to be used for preview in my CMS system. This was possible in the previous versions of nextJS since we used to run npm run export rather than have output: 'export' in next.config.js