I hope this solves your problem.
- Check if the .env.local file is correctly located in the root.
- Use console.log(process.env) to debug which variables are available.
- Ensure dotenv is installed and correctly loaded if running outside Next.js.
- Ensure you are not adding the NEXT_PUBLIC_ prefix to MONGODB_URI, as it is meant for server-side usage.
Thanks.
Good Luck!