Skip to content

Install dotenv package and replace the explictly mentioned database host path with process.env.MONGODB_URI #2

@tusharkhatriofficial

Description

@tusharkhatriofficial
  • Install dotenv package using npm i dotenv
  • Create a new file .env and add MONGODB_URI=mongodb://localhost:27017/blogDB or your local/remote equivalent
  • Replace mongoose.connect("mongodb://localhost:27017/blogDB", {useNewUrlParser: true, useUnifiedTopology: true}); with mongoose.connect(process.env.MONGODB_URI, {useNewUrlParser: true, useUnifiedTopology: true}); in app.js
  • Do not forget to add .env to .gitignore file.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions