Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
It only makes sense to store in vuex if this value changes (based on the name, this is unlikely). Vue.prototype.$baseUrl
and window.baseUrl
not the most elegant solution, because not all components need this constant.
I would create some config.js and in it
and where you need to read --
In my opinion, if you do not use any DI , this is the cleanest solution.
If we are talking specifically about storing baseURL to access the API, then use environment variables - this is the most correct option. Using this approach, you can easily redefine this variable when starting the project in different environments (dev, production) without changing the application code itself.
For example, an article.
Simply put, in your code you write something like:
And start the NodeJS server with the following command:
PS The most common package for working with env re... NodeJS documentation
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question