URL shortener project working locally but not on server (Heroku)

I´ve just finished the URL shortener project.

It works fine locally, but it doesn´t work on the server, in this case on Heroku.

I´m wondering if it´s because the .env file is not on Github? I added the environment secrets on Github manually. But it still does not work.

The name of the secret is: MONGO_URI

The value is: mongodb+srv://@cluster0.rbrbp.mongodb.net/myFirstDatabase?retryWrites=true&w=majority

I connect to the server this way:

mongoose
  .connect(process.env.MONGO_URI, {
    useNewUrlParser: true,
  })
  .then(() => {
    console.log("Connection state = " + mongoose.connection.readyState);
  });

I found out that I had to add the environment secret manually on Heroku. It´s fine now.