Couldnt get Cloudflare Pages edge functions working with nextjs api
Tried to get static blog with api edge routes from nextjs to work via https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/#deploy-a-nextjs-site and npx @cloudflare/next-on-pages@1
but the build command kept failing with
⚡️ Invalid prerender config for posts/[id].prerender-config.json ⚡️ Invalid prerender config for posts/[id].rsc.prerender-config.json ⚡️ ERROR: Failed to produce a Cloudflare Pages build from the project. ⚡️ ⚡️ The following functions were not configured to run with the Edge Runtime: ⚡️ - [id].rsc.func ⚡️ - [id].func ⚡️ ⚡️ If this is a Next.js project: ⚡️ ⚡️ - you can read more about configuring Edge API Routes here: https://nextjs.org/docs/api-routes/edge-api-route ⚡️ ⚡️ - you can try enabling the Edge Runtime for a specific page by exporting the following from your page: ⚡️ ⚡️ export const config = { runtime: 'edge' }; ⚡️ ⚡️ - or you can try enabling the Edge Runtime for all pages in your project by adding the following to your 'next.config.js' file: ⚡️ ⚡️ const nextConfig = { experimental: { runtime: 'edge'} }; ⚡️ ⚡️ You can read more about the Edge Runtime here: https://nextjs.org/docs/advanced-features/react-18/switchable-runtime
So Im going to use Cloudflare Functions
via the /functions
lib and keep nextjs just handling the static site for now.