Nuxt SSR and .env

If you are using runtime config with Nuxt (see Runtime Config · Nuxt Advanced), in a production environment Nuxt will not load from .env, it will only pull from platform environment variables.

The only way I can see to do that with Cleavr is to add the .env to the pm2 config in build settings. But that means I’m managing environment variables in two places (in two different formats) because Nuxt still uses the .env during the build process (I think).

Is there a better way to do this or is this it? I suppose the .env doesn’t change a lot but it’s still a footgun imho.

Hello @interfacelab and welcome to the Cleavr forum!

I assume you’re using Nuxt v3? They made some changes around using .env in prod as you mentioned. You can add needed variables to the PM2 Ecosystem environment section for the time being as we come up with a solution to better manage them.

Is there any fix now? Because I’ve had the same problem. When using .env variables my Nuxt 3 App caused always 100% CPU usage and 502 Nginx error.
My solution was to remove .env variables for now…