How to pass a variable I have on server (process.env.SERVER) to the browser

On the frontend server I have a file I can read with:

if(!!process.env.SERVER) {
  require("dotenv").config( { path: '/hw/.env', debug: true } )
  console.log(process.env.myvar)
}

But how can I pass the vlue of process.env.myvar to the browser?

Thanks.

Prefix custom env variables with VUE_APP_

https://cli.vuejs.org/guide/mode-and-env.html#environment-variables

Hi.

thanks for answering.

I added the prefix VUE_APP_ to the variable in an .env file in the frontend root folder but it’s no part of the process.env variables.

Maybe this VUE_APP_ thing is just for vue3. I am still using vue2.

Cheers.

No, it’s Vue 2 as well. After you added it, did you restart your dev server?

Yes. I restarted the server (I have it running withy nodemon).

I finally made it work with vuex.
In the server (!!process.env.SERVER) I read the variable and save it in vuex and then in the frontend, somehow, the value is there.

Thanks.