You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/mode-and-env.md
+10-4Lines changed: 10 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -43,10 +43,16 @@ An env file simply contains key=value pairs of environment variables:
43
43
44
44
```
45
45
FOO=bar
46
-
VUE_APP_SECRET=secret
46
+
VUE_APP_NOT_SECRET_CODE=some_value
47
47
```
48
48
49
-
Note that only variables that start with `VUE_APP_` will be statically embedded into the client bundle with `webpack.DefinePlugin`.
49
+
::: warning
50
+
Do not store any secrets (such as private API keys) in your app!
51
+
52
+
Environment variables are embedded into the build, meaning anyone can view them by inspecting your app's files.
53
+
:::
54
+
55
+
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`. It is to avoid accidentally exposing a private key on the machine that could have the same name.
50
56
51
57
For more detailed env parsing rules, please refer to [the documentation of `dotenv`](https://github.com/motdotla/dotenv#rules). We also use [dotenv-expand](https://github.com/motdotla/dotenv-expand) for variable expansion (available in Vue CLI 3.5+).
52
58
@@ -87,10 +93,10 @@ In both cases, the app is built as a production app because of the `NODE_ENV`, b
87
93
You can access env variables in your application code:
88
94
89
95
```js
90
-
console.log(process.env.VUE_APP_SECRET)
96
+
console.log(process.env.VUE_APP_NOT_SECRET_CODE)
91
97
```
92
98
93
-
During build, `process.env.VUE_APP_SECRET` will be replaced by the corresponding value. In the case of `VUE_APP_SECRET=secret`, it will be replaced by `"secret"`.
99
+
During build, `process.env.VUE_APP_NOT_SECRET_CODE` will be replaced by the corresponding value. In the case of `VUE_APP_NOT_SECRET_CODE=some_value`, it will be replaced by `"some_value"`.
94
100
95
101
In addition to `VUE_APP_*` variables, there are also two special variables that will always be available in your app code:
0 commit comments