Set an if clause to check if MONGO envs are present; if so, use connection string with envs; if else, use connectionString at localhost without security. code example
Example: mongodb local connection string
mongodb://localhost:27017/mydbname
mongodb://localhost:27017/mydbname