next-on-pages process.env values are undefined
Hey! I was wondering if anyone has faced an issue where process.env values, such as process.env.NEXT_PUBLIC_API_URL is coming through as undefined on build? Both on deploy and preview with pages.
In standard next development mode it works fine. I tried a normal next static export and serving that on a simple server, and that works fine. So somewhere in the cf build process I seem to be losing these values.
I’m not using any of the cf services directly in this pages app, all that happens on a standalone worker (which is the api url im trying to connect to).
This only happened when I migrated my code over to cloudflare from render. They were both set up nearly identically, with the env values being set in the environment variables section of the dashboard.
As a sanity check I also tried moving my logic into a clean vite app, which also worked with the vite env syntax.
Am i misunderstanding something basic about how cloudflare handles env values? I do not have a wrangler.toml for this next app, everything is handled in the repo and the environment variables in dashboard and a .env file locally.
Any help would be appreciated, thank you!
In standard next development mode it works fine. I tried a normal next static export and serving that on a simple server, and that works fine. So somewhere in the cf build process I seem to be losing these values.
I’m not using any of the cf services directly in this pages app, all that happens on a standalone worker (which is the api url im trying to connect to).
This only happened when I migrated my code over to cloudflare from render. They were both set up nearly identically, with the env values being set in the environment variables section of the dashboard.
As a sanity check I also tried moving my logic into a clean vite app, which also worked with the vite env syntax.
Am i misunderstanding something basic about how cloudflare handles env values? I do not have a wrangler.toml for this next app, everything is handled in the repo and the environment variables in dashboard and a .env file locally.
Any help would be appreciated, thank you!