Authentication issue with Next.js app deployed on Netlify

Hello everyone,

I recently deployed my Next.js app on Netlify, and I’m encountering authentication problems. The app works perfectly fine on my local machine, but after deployment, the login functionality and registration process are not functioning correctly.

I have already checked my environment variables, and they seem to be configured correctly:


To provide further context, I have deployed my app at the following link: []

Additionally, you can find my app’s code on GitHub: [GitHub - jondereck/stay]

I would greatly appreciate any insights, suggestions, or troubleshooting steps that could help me resolve this authentication issue.

Thank you so much for your assistance!

Based on the way the error appears in your dev tools, I’m assuming it’s the timeout error. If yes, please follow: [Support Guide] Why is my function taking long or timing out?

I tried the solution above but still does not work

I managed to resolve the issue! Here’s how I did it: I granted unrestricted network access to my MongoDB server, which enabled successful connections from my application.

To tackle the problem, I first checked the MongoDB configuration to ensure it was correctly set up and operational. I verified the connection URL and credentials in my application’s configuration files, and all seemed fine on that front. Next, I made sure that there were no network restrictions or firewalls blocking the connection, which might have been the cause of the server selection timeout.

Upon examining the MongoDB server’s status, I found that it was up and running without any apparent errors. However, I noticed that my application was trying to connect to a MongoDB replica set, which prompted me to reevaluate my connection settings. After carefully reviewing the connection string and adjusting it to the correct replica set settings, I still encountered the same error.

Eventually, I realized that the MongoDB security settings were quite restrictive, which prevented my application from connecting properly. As a solution, I decided to loosen the network access permissions on my MongoDB server. This involved allowing all incoming connections from my application’s environment, effectively granting unrestricted access to the database.

By taking this approach, the Prisma client successfully established connections with the MongoDB server, and the server selection timeout error was resolved. My application was then able to query the database without any issues, and everything worked flawlessly.

I also made sure to handle any potential errors more gracefully within the application, ensuring that users received meaningful error messages if there were any future issues with the database connection.

This experience has taught me the importance of carefully configuring database access and security settings, and how they can impact the overall functionality of an application. I’ll keep these lessons in mind for future projects to ensure smooth and secure database interactions.