Using Wrangler environments and the Nuxt template
Hi everyone, this is my first time using cloudflare so sorry if I'm missing something obvious!
I've created a Nuxt project with the help of
npm create cloudflare I then deployed it successfully with no changes. Now I want to setup environments so I can run a separate dev worker with a separate D1 database and then deploy them from GitLab.
So I made the following changes to the wrangler file:
2 Replies
At first I thought I could use
--env prod but then realised after trying that I can't do that because of vite generating a flattened file at build (I think).
So I then changed the build command instead to this CLOUDFLARE_ENV=prod npm run build but then got this error:
I then tried setting the environment variable then building locally and then looked at .output/server/wrangler.json which was:
So it appears it's not being flattened?
If more info is needed let me know, Thanks in advanced!🙂After a bit more investigating I realised that the wrangler config is generated by nitro and you actually don't really need a wrangler file setup. You can specify everything within the
nuxt.config.ts which allows you to use it's environment overrides. It might be easier to just make a Nuxt project then add Cloudflare in. https://nitro.build/deploy/providers/cloudflare https://nuxt.com/docs/4.x/getting-started/configuration#environment-overridesCloudflare - Nitro
Deploy Nitro apps to Cloudflare.
Nuxt
Configuration · Get Started with Nuxt v4
Nuxt is configured with sensible defaults to make you productive.