bencodezen / vue-enterprise-boilerplate

An ever-evolving, very opinionated architecture and dev environment for new Vue SPA projects using Vue CLI.
7.77k stars 1.32k forks source link

Loading Environment Valiables #109

Closed suhirthan closed 5 years ago

suhirthan commented 5 years ago

When trying to run yarn dev only Env variable which have the prefix VUE_APP seems to be loading other such as the API_BASE_URL are being ignore when passed as mentioned in the document. Is this something that is a configuration.

frandiox commented 5 years ago

Vue CLI works like that. https://cli.vuejs.org/guide/mode-and-env.html#using-env-variables-in-client-side-code I think you'll need to rename your frontend vars to VUE_APP_*

suhirthan commented 5 years ago

Thanks, solved. Might have to change the vue.config.js file to match this.

chrisvfritz commented 5 years ago

@suhirthan The way the project is set up, you should never actually need access to the API_BASE_URL in your application code. Would you mind sharing the use case you ran into?

chrisvfritz commented 5 years ago

Closing this due to inactivity, but happy to reopen if need be. 🙂

banavasi commented 5 years ago

Having the same problem here. Please can anyone help? I need to change the base url its taking by default the localhost:8080 i need to point to some other ref. I am using vue cli 3 used the VUEAPP* reference i could print the variable in the console but the host value is not changing when I call the Api, I updated the vue.config file as well no change.

chrisvfritz commented 5 years ago

See publicPath in the Vue CLI docs:

https://cli.vuejs.org/config/#publicpath

suhirthan commented 5 years ago

Having the same problem here. Please can anyone help? I need to change the base url its taking by default the localhost:8080 i need to point to some other ref. I am using vue cli 3 used the VUEAPP* reference i could print the variable in the console but the host value is not changing when I call the Api, I updated the vue.config file as well no change.

Did you manage to solve this issue?

PhyberApex commented 4 years ago

Just as a little heads up, if you add the public path option you also need to set the base in the router to that path or else the routing wont work. Took me some time to figure that one out.