From the course: React: Creating and Hosting a Full-Stack Site
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Defining environment variables - React.js Tutorial
From the course: React: Creating and Hosting a Full-Stack Site
Defining environment variables
- [Instructor] All right, so at this point we've set up hosting for MongoDB, so we're almost ready to release. The last thing we need to do here is we need to make sure that we specify the correct URL for connecting to MongoDB, depending on the environment. Now, we set those environment variables a little while ago inside this .env file, and we're actually going to move those over to another file in this video. We'll see how to do that shortly. But first, what we're going to do is we're going to change this URI, depending on whether or not there is an environment variable here called MONGODB, and then we'll say USERNAME, all right? If there's not, then what we're going to do is we're just going to use the localhost version. We'll assume that we're supposed to be trying to connect to a local instance of MongoDB. Otherwise, we're going to use a very similar connection string to what we just used in the terminal to connect through the shell. And in order to make sure that we get this…