Problem: When using process.env.XXX, the value of the environment variable cannot be obtained:
axios.defaults.baseURL = process.env.VUE_APP_BASE_API;
solve:
One: In the .env.development and .env.production environment configuration files in the project root directory, the value of NODE_ENV= development must be consistent with the startup configuration --mode of the package.json file
//.env.development
NODE_ENV=development
VUE_APP_BASE_API=/api
VUE_APP_BASE_URL=http://localhost:8081/
VUE_APP_PROXYURL=http://localhost:8080/
"scripts": {
"serve": "vue-cli-service serve",
"dev": "vue-cli-service serve --mode development",
"prod": "vue-cli-service serve --mode production",
},
Two: The variable names in the .env.development and .env.production environment configuration files must start with VUE_APP_