If you have a deployment target dependent API URL to fetch data from during server side render and also during client-mode, it is impossible right now, to define an env var during run time. (nuxt vs nuxt build).
Right now, the only option is to build for the deployment target.
It would be nice to have the possibility to define an environment variable, that can be set when running nuxt. That would only work with the nuxt server. generate and --spa would not work
馃憤 I tried https://nuxtjs.org/api/configuration-env/ but didn't realised this only works before build :(
You can use module https://github.com/samtgarson/nuxt-env
Just wish that was documented before fiddling with it for hours. Thanks!!
@MartinMuzatko feel free to send a PR to https://github.com/nuxt-community/awesome-nuxt :relaxed:
You can use module https://github.com/samtgarson/nuxt-env
Unfortunately this does not work in SPA mode. Anyone find a way to do this when in SPA mode.