Nuxt.js: runtime env vars

Created on 16 Jan 2019  路  6Comments  路  Source: nuxt/nuxt.js

What problem does this feature solve?

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.

What does the proposed changes look like?

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

This feature request is available on Nuxt community (#c8486)
feature-request

All 6 comments

馃憤 I tried https://nuxtjs.org/api/configuration-env/ but didn't realised this only works before build :(

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vadimsg picture vadimsg  路  3Comments

surmon-china picture surmon-china  路  3Comments

maicong picture maicong  路  3Comments

mattdharmon picture mattdharmon  路  3Comments

jaredreich picture jaredreich  路  3Comments