MERN App Deployment
Create two folders for your Project
backend and frontend
1.) Make gitignore file both in frontend and backend and hide the node modules and .env file
2.) Now push all the code in a github repository
3.) Go to render.com
- Connect render acc with github.
- Choose the repo you created.
- Carefully enter below details
Name : (any)
Branch : master
Root directory : backend
Build cmd : npm run build
Start cmd: npm run start
Add Environment Variables
Two ways : 1.) Add secret file(.env file)
2.) Add each variable like below
Note: Start the deployment make sure that mongodb ip address is whitelisted (Make the ip to access from anywhere). Also if node version problem comes then make a .node-version in frontend and add the version which is required.
Server will be Live After Deployment.....
******************IMP*******************
Now some URL will be there like this
https://happyfood.onrender.com
take that URL and replace all the
http://localhost:3001/ present at the frontend with
https://happyfood.onrender.com/eg: https://happyfood.onrender.com/api/user
After that run : npm run build
and build folder will be created
push all the changes to the Github
Once done GO TO netlify and drop the build folder
Wait for sometime and then your site will be ready to go......
Comments
Post a Comment