I have deployed my Next.js 13 app on Cloudflare Pages. Since it has a few API routes, I had to export the runtime variable from each route as follows.
export const runtime = "edge"
However, when I do local development, I need to change this to 'nodejs'. Therefore I tried supplying this value through a Next.js environment variable, but it's not working on Cloudflare.
Does anyone know an easier way to toggle between these two runtimes for prod and dev? Thanks in Advance!
I think we can archive your issue by use the .env file to config the variables in production or development. With
.envfor production and.env.localfor development.Updated: Go to the file
next.config.jsand add a config:Now we can use this config with
next/configpackage. Eg.It works for me.