I am trying to use environment variables in my nuxt 2.15.8 project for development and production. First i used .env file and then i saw in the documentation that i can use runTimeConfig as best practice.
So i tried to use:
// nuxt.config.js
export default {
publicRuntimeConfig: {
apiUrl: process.env.API_URL,
bucket: process.env.BUCKET,
},
privateRuntimeConfig: {
passwordEncryptKey: process.env.PASSWORD_ENCRYPT_KEY,
}
}
And then i my vue files this.$config.apiUrl
For publicRuntimeConfig it works and i can see the variables but for privateRuntimeConfig it doesn't work
How can i use privateRuntimeConfig
in my project?
for example i need to use them inside the "methods" property or in the "data" property but without exposing them to the browser?
Or should i use some other way instead of privateRuntimeConfig
?