Last edit: 2025-01-03
Set up your enviornment variables.
Create a .env file in the root of the mongate-back-end directory.
//mongate-back-end/.env
MONGO_URI=mongodb://localhost:27000
JWT_SECRET=JWT_SECRET
PORT=8080
RESEND_API_KEY=RESEND_API_KEY
CORS_ORIGIN=http://localhost:3000
NODE_ENV=development
This is the URI of your MongoDB database. You can get a MongoDB cluster from various places but the most popular is MongoDB Atlas for production. For development you can download MongoDB locally with their community server This allows you to work offline and more efficiently.
JWT (Json Web Tokens) are used for authentication and password encryption.
You can generate a JWT Secret yourself with an OpenSSL Terminal
openssl rand -base64 32
Or, you can generate a JWT Secret easily online with JWT.io
This is the port that the back end will run on. The port is set to 8080 by default. You can change this if you'd like.
Resend is the email service. You need your own domain to use it.
I recconemd using Namecheap for your domain.
You can sign up for a free account and get your API key at Resend
This is the URL of your front-end. The back-end will only accept requests from this URL with CORS. This is located in back-end/api/index.ts
Leave this blank in development but in deployment set this to production, this allows you to use the production build of the app.
You will also need to add these variables to wherever you decide to deploy your app. I personally reccomend using Railway
Create a .env file in the root of the mongate-front-end directory.
//mongate-front-end/.env
NEXT_PUBLIC_BACK_END_URL=http://localhost:8080
For the front end, you will need to set the URL of the back end. This is the URL that the front end will use to make requests to the back end.