DEV Community

Discussion on: Building User Accounts with Nuxt, Vuex, and Firebase

Collapse
 
abelmoremi profile image
Abel Moremi

great article by the way... Oh Hi...

I was wondering how you implement firebase.js plugin with ENV variables... as you know to commit API keys is not a healthy practice. I have been trying it out with no luck and little insight to it would be really helpful. Thank you

Collapse
 
tb_95 profile image
TomBell_95

Did you manage to solve this issue? I am facing the same problem and the only solution would be to migrate the firebase config to nuxt.config.js ?

Collapse
 
drewclem profile image
Drew Clements

For this, you'd create a .env file and store your keys there. Then you'd setup your nuxt.config.js to use those variables as well.

From there, you'd use process.env.YOUR_KEY where you needed to access the key.

Thread Thread
 
tb_95 profile image
TomBell_95

Thanks for replying, I have been working on this for over a week and seems like this is the only fix so far: stackoverflow.com/questions/703036...

Thread Thread
 
drewclem profile image
Drew Clements

This kind of a gotcha with JAMstack sites and authentication, because at some level, the keys will be exposed somewhere within the compiled code.

However, using the .env and nuxt.config.js route will at least keep them out of the repo.

I haven't built anything with this setup that gets enough traffic to warrant going the extra mile for the extra security.

I don't know of a workaround for this.

Thread Thread
 
tb_95 profile image
TomBell_95

Completely agree, I have been struggling with this for a week and wanted to finish my app with the best practise but from looking at what the community is saying, its a common problem. Thanks mate.