While using the Google Map API, I just wrote the API I got and pushed it on Git Hub. Then I got this email from Git Hub ... GitGuardian has detected the following Google Key exposed within your GitHub account. ** GitGuardian has detected the following Google keys published within your GitHub account: ** ** Great! I was impressed that GitHub can do such a thing. I'm not impressed, so I immediately put it in an environment variable and tried to change the description, so please share it
And there are many things you can set environment variables for, so try to find a good one for yourself! In my case, I use ** zsh ** to set environment variables.
For beginners: Introduction of Zsh This article was very easy to understand! Please install Zsh from this article
% vim ~/.zshrc
Open .zsher in Then I think the screen looks like this Since I have already set various settings, there are many contents described, but please ignore it ** When this screen opens, please enter "i" for the time being ** At the bottom left
-- INSERT--
This is called ** insert mode ** Because you will be able to input
export Variable name you want to use='Value you want to hide' #Please be careful not to put a space in the equal
Example
export GOOGLE_MAP_API='hoge'
If you write like this, the setting is completed
The command to exit insert mode is ** esc key ** exit After exiting ** ": wq" ** when saving settings ** ": q!" ** when not saving Please end with
afterwards Reload .zshrc and enable defined environment variables
source ~/.zshrc
This completes the environment variable settings.
Basically
ENV['Environment variables set']
And use When writing API KEY in view by using API
<%= ENV['Environment variables installed'] %>
Write That's it!
Recommended Posts