404 errors in dynamic and api routes on Cloudflare Pages with Next.js

Hello everyone,

I’m having an issue with dynamic routes and API routes in Cloudflare Pages. Currently, everything inside the api route and any request to a dynamic page is returning a 404 error. I’m using the latest version of Next.js without the /app directory, and I used the normal Next.js preset when creating my project in Cloudflare Pages.

I’ve also set my environment variables to use NODE_VERSION: 16.18.0 because the build process won’t work without it. Despite this, I’m still facing issues with the dynamic routes and API routes.

I’m hoping someone can provide some insight into what might be causing this issue and how I can resolve it. Any help or suggestions would be greatly appreciated.

Thank you!