[英]How to hide my password when deploying nodejs through FTP
How to hide my password when deploying nodejs through FTP?通过FTP部署nodejs时如何隐藏我的密码? It seems the following code will be seen by everyone in GitHub repository.
似乎下面的代码会被 GitHub 存储库中的每个人看到。 Also, when people download my file, they can also see the password.
此外,当人们下载我的文件时,他们也可以看到密码。 How to avoid this problem?
如何避免这个问题? Thank you very much!
非常感谢!
const Client = require('ftp');
const connectionProperties = {
host: 'ftp.example.com',
user: '',
password: '12345678'
Use dotenv to retreive all environment variables from .env
file.使用dotenv从
.env
文件中检索所有环境变量。
npm install dotenv
HOST=ftp.example.com
PASSWORD=12345678
const dotenv = require('dotenv')
dotenv.config()
const Client = require('ftp');
const connectionProperties = {
host: process.env.HOST,
user: '',
password: process.env.PASSWORD
Please note that you should edit
.gitignore
file ignore.env
file from the git source control.请注意,您应该编辑
.gitignore
文件,忽略来自 git 源代码管理的.env
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.