cloudflareでデプロイしていたブログをverselに移行した話

更新日:

cloudflareにデプロイしていたコードをそのままverselでデプロイしてみたところエラーが出た。

Error: The Edge Function "post/[id]" size is 1.17 MB and your plan size limit is 1 MB. Learn More: https://vercel.link/edge-function-size

edgeを使っているページには以下のコードがある

export const runtime = "edge";

このコードを以下のコードに変える

export const dynamicParams = false;

これで「動的ルートは使わない、generateStaticParams で定義されたものだけを使う」と明示できます。

そしたらエラーが出なくなりデプロイが成功した。

ちなみにこの修正をすればcloudflareでも課金をせずにデプロイできるのかと思い試してみた所以下のエラーが出た。

⚡️ ERROR: Failed to produce a Cloudflare Pages build from the project.
⚡️ 
⚡️ 	The following routes were not configured to run with the Edge Runtime:
⚡️ 	  - /post/category/[category]/page/[page]
⚡️ 	  - /post/tag/[tag]/page/[page]
⚡️ 
⚡️ 	Please make sure that all your non-static routes export the following edge runtime route segment config:
⚡️ 	  export const runtime = 'edge';
⚡️ 
⚡️ 	You can read more about the Edge Runtime on the Next.js documentation:
⚡️ 	  https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes
Failed: Error while executing user command. Exited with error code: 1
Failed: build command exited with code: 1
Failed: error occurred while running build command

ただcloudflareでも課金をせずにデプロイするのは今回の趣旨では無いのでスルーすることとする。