Next.js API /health throwing 500 on Cloudflare Pages with @cloudflare/next-on-pages
REST API❓Other (read rules)✅Solved
We have an existing Next.js application deployed on Cloudflare Pages using the package @Cloudflare/next-on-pages.
Recently, we added a simple API endpoint /health as part of plans to make the app fullstack. After deploying to Cloudflare Pages:
The frontend works fine
The API endpoint /health returns Internal Server Error (500)
Some additional context:
We are using Next.js 14.2.21
The package @Cloudflare/next-on-pages is deprecated
The API works locally, only fails in the deployed environment
Has anyone encountered this issue? What is the recommended way to serve Next.js API routes on Cloudflare Pages now that @Cloudflare/next-on-pages is deprecated?