Answers for "how to change env variable in vue project"

PHP
3

Add Laravel .env variable to Vue component

in windows :

thats worked for me without any require in webpack.mix

... just add a new variable in env file with this prefix : MIX_

MIX_API_URL=http://laravel:8000
but need to restart php artisan serve and also restart npm run watch....

  let api_url = process.env.MIX_API_URL;
  console.log("my env variable:");
  console.log(api_url);
Posted by: Guest on June-17-2021
0

vue not loading env variables

Note that only NODE_ENV, BASE_URL, and variables that start with VUE_APP_
will be statically embedded into the client bundle with webpack.DefinePlugin

So you may need to add VUE_APP_ prefix to your variables.
Posted by: Guest on March-05-2022

Code answers related to "how to change env variable in vue project"

Browse Popular Code Answers by Language