This application has been configured to be deployed on Vercel. Follow these steps to deploy:
- A Vercel account
- MongoDB Atlas database (or any MongoDB provider)
- Node.js installed locally
You'll need to set up the following environment variables in your Vercel project:
MONGODB_URI: Your MongoDB connection string (must include database name)- Format:
mongodb+srv://<username>:<password>@<cluster>.mongodb.net/<database>?retryWrites=true&w=majority - Example:
mongodb+srv://username:password@cluster.mongodb.net/smartbite?retryWrites=true&w=majority - Make sure to replace
<username>,<password>,<cluster>, and<database>with your actual values - Important: Include the database name before the query parameters (e.g.,
/smartbite?)
- Format:
ACCESS_TOKEN_SECRET: Secret for JWT access tokensREFRESH_TOKEN_SECRET: Secret for JWT refresh tokensNODE_ENV: Set toproductionfor deployment
Note: If you're experiencing authentication issues, verify that:
- Your MongoDB Atlas username and password are correct
- Your IP address is whitelisted in MongoDB Atlas Network Access settings
- The database name is correctly specified in the connection string
-
Install Vercel CLI (optional):
npm install -g vercel -
Login to Vercel (if using CLI):
vercel login -
Deploy your application:
vercel
If you encounter errors during deployment, check the following:
- Authentication Failed: Verify your MongoDB username and password in the connection string
- IP Access List: Make sure Vercel's IP addresses are whitelisted in MongoDB Atlas (or enable "Allow access from anywhere")
- Database Name: Ensure your connection string includes the database name before query parameters
- Connection String Format: Double-check the format of your MongoDB URI
- Make sure
server.jsexports the Express app withmodule.exports = app; - Verify that all middleware and routes are properly configured
- Check that all required environment variables are set in Vercel project settings
- Ensure environment variables are properly accessed in your code
vercel
- Push your code to a Git repository (GitHub, GitLab, or Bitbucket)
- Import the repository in the Vercel dashboard
- Configure environment variables
- Deploy
- Clone the repository
- Create a
.envfile based on.env.example - Install dependencies:
npm install - Run the development server:
npm run dev
/config- Configuration files/controllers- Route controllers/middleware- Express middleware/model- Data models/public- Static assets/routes- API routes/views- HTML templates
- Node.js
- Express.js
- MongoDB
- JWT Authentication