Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear the text if switched from Login page to Sign Up page #5

Open
ayush0801 opened this issue Oct 1, 2023 · 4 comments
Open

Clear the text if switched from Login page to Sign Up page #5

ayush0801 opened this issue Oct 1, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest

Comments

@ayush0801
Copy link
Owner

The details entered in the login page should be cleared if switched to the Create Account page and vice-versa.

@ayush0801 ayush0801 added enhancement New feature or request good first issue Good for newcomers hacktoberfest labels Oct 1, 2023
@mohak34
Copy link

mohak34 commented Oct 1, 2023

hey id like to work on this issue

@mohak34
Copy link

mohak34 commented Oct 1, 2023

@ayush0801 i am having problems connecting to the mongodb server can you provide me with the instructions on how to add the connection string to the .env file

@ayush0801
Copy link
Owner Author

Adding MongoDB Connection String to the .env File

If you are facing issues connecting to the MongoDB server for your Node.js project, you can follow these steps to add the MongoDB connection string to the .env file:

  1. Create a MongoDB Atlas Account (if you haven't already):

  2. Create a Cluster:

    • After logging in, click on the "Build a Cluster" button to create a new MongoDB cluster.
    • Follow the setup steps, selecting your preferred cloud provider and region.
  3. Create a Database User:

    • In the MongoDB Atlas dashboard, navigate to your cluster's details.
    • Under the "Security" section in the left sidebar, click on "Database Access."
    • Click on "Add New Database User" and set a username and password for this user.
    • Note down the username and password; you will need them later.
  4. Assign Privileges:

    • Under the "Database Access" section, click on "Add Default Privileges" for the user. You can use the "Atlas Admin" role for development, but it's recommended to assign specific roles for production.
  5. Whitelist Your IP Address:

    • In the MongoDB Atlas dashboard, under the "Security" section, click on "Network Access."
    • Click "Add IP Address" and add your current IP address to the whitelist. This allows your local development environment to access the MongoDB cluster.
  6. Retrieve the Connection String:

    • In the MongoDB Atlas dashboard, click on your cluster to access its details.
    • Under the "Connect" button, click on "Connect Your Application."
    • Choose the connection method as "Node.js" and copy the provided connection string.
  7. Add the Connection String to Your .env File:

    • In your project directory, create a .env file if you don't already have one.

    • Open the .env file in a text editor.

    • Add a variable to store your MongoDB connection string. You can name this variable MONGODB_URI. Paste the connection string you copied in the previous step into the .env file. It should look something like this:

      MONGODB_URI=mongodb+srv://<username>:<password>@cluster-name.mongodb.net/database-name
    • Replace <username>, <password>, cluster-name, and database-name with the values you set up in your MongoDB Atlas account.

  8. Load Environment Variables (Optional):

    • To access the MongoDB connection string in your Node.js application, you can use a package like dotenv.

    • Install dotenv by running npm install dotenv if you haven't already.

    • In your Node.js application's entry point (e.g., app.js or server.js), add the following code at the top:

      require('dotenv').config();
    • Now, you can access the MongoDB connection string using process.env.MONGODB_URI in your application code.

Remember to keep your .env file secure, as it contains sensitive information. Do not share it publicly or commit it to version control (e.g., Git). You should add it to your project's .gitignore file to prevent accidental commits.

@mohak34
Copy link

mohak34 commented Oct 1, 2023

@ayush0801 I followed the instructions exactly but when i go with npm start i get this error " Error while connecting to the database MongoServerError: bad auth : Authentication failed. "
I rechecked all the credentials but it seems to have no effect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

No branches or pull requests

2 participants