#Request env variables on application startup from backend

29 messages · Page 1 of 1 (latest)

sullen idol
#

Hi, I want to request environment variables once my frontend loads. I have a java backend where all the configuration is located. Is there any specific hook available which I could use to load the env variables or is the best option to just send a request in my app.vue entry point?

dreamy hedge
#

this depends highly on your application, typically you would supply env variables when building your app and/or launching the process

#

but it may make sense to feed your configuration in another way if you have a lot of config (i.e. if it doesn't make sense to put the config in the actual env)

sullen idol
#

Yeah currently I have the env variables in the frontend which are required. But some are duplicated because they are also needed in the backend. Therefore I now want to request them from the backend. And now I'm basically asking what's the best way to request them. Is there any specific listener/hook I can use or do I just request them once in my app.vue Would be nice if it even is possible no load them once in a while with the nuxt/vue server so I don't even have to make a dedicated request from the frontend

dreamy hedge
hallow iris
dreamy hedge
#

yeah it really depends on your implementation, there's a lot of ways to do it

hallow iris
#

but setting in plugin is the recommended way

#

since plugins run before any of the UI logic runs

#

so you can get consistent state

dreamy hedge
#

setting with env variables and using runtimeconfig is recommended

#

but, that's not always possible

#

sounds like you're doing some special stuff

hallow iris
#

Yes ofcource, when you can't do that

dreamy hedge
sullen idol
dreamy hedge
sullen idol
#

And you do not use the runtime config at all right? Like you don't set it dynamically?

hallow iris
sullen idol
hallow iris
sullen idol
hallow iris
#

never do that, it will lead to weird states

#

do one thing, inside the plugin, read from runtime config, and set to state

#

then modify the state

#

this happens in my case as well

hallow iris