DEV Community

Discussion on: How to load dynamical environment variables with Nuxt.js

mrnaif2018 profile image

Hi! Of course it doesn't work neither in SPA nor in full static
Where would it get env variables from? Client browser? 😀
It works in SSR mode only, it's whole point is to be able to change some variables server-side after build. Full static mode just generates ready html for use with static hosting. It's just html files which can't use anything from the server. Same goes for SPA

kissu profile image
Konstantin BIFERT

I actually achieved it with SPA without too much trouble (publicRuntimeConfig is dope simple to use in fact). :D
But yeah, it does probably not work in full static or maybe with some hacky stuff like this one:

And yeah, I do agree that it's probably not feasible in full static for obvious reasons but who knows, it was maybe a cool way of handling this one.

Still thanks for the quick reply and have a great day. 😃