1.config폴더를 생성하고 그 안에 dev.js, key.js, prod.js파일을 생성한다.
2. dev.js는 로컬환경일때, prod.js는 배포 후일때, key.js는 환경변수에 따라 정보를 어떻게 처리할지 정의해준다.
module.exports = {
mongoURI: "mongodb+srv://eodbszla:<password>@cluster0.7lq41.mongodb.net/myFirstDatabase?retryWrites=true&w=majority"
}
module.exports = {
mongoURI: process.env.MONGO_URI
//heroku에서 설정한 키명이랑 동일해야 한다.
}
if(process.env.NODE_ENV === 'production') {
//배포 후
module.exports = require('./prod')
}
else {
//로컬환경
module.exports = require('./dev')
}
3.index.js의 비밀정보부분을 변수처리하기
const config = require('./config/key');
mongoose.connect(config.mongoURI)
.then(()=>console.log('MongoDB Connected...'))
.catch((err)=>console.log(err));
dev.js를 .ignore에 명시하여 github에 올라가지 않게 하기
node_modules
dev.js
Finding an online casino that fits perfectly with Canadian players can be challenging, but Power Play has made it much simpler. This site dedicates itself to listing and reviewing casinos that are well-suited for the Canadian audience. Last month, when I was looking to enjoy some casino games on a lazy Sunday, this site provided me with a great selection, making my choice easy and the day enjoyable.