DEV Community

Cover image for How to Setup and Deploy a MERN stack project for FREE 🌐🚀

How to Setup and Deploy a MERN stack project for FREE 🌐🚀

Kunal Ukey on March 19, 2023

Introduction: If you're a developer who's just starting out with the MERN stack, you may be wondering how to deploy your project for...
Collapse
 
vasip2f profile image
vasip2f

after deployemnt i try to post the data frontend to backend it's perfectly send the data...but after page refresh it's show page not found...

Collapse
 
kunalukey profile image
Kunal Ukey • Edited

@vasip2f Can you provide more details?

Collapse
 
precupeduard2 profile image
Precup Eduard

Hi @vasip2f . That may be caused because the page name is looking for after refresh.
Let's say you have a get request for data in a page yoursite/api/get. After refresh it may looking only for /api/get, so it means you will have to set a redirect in your express server.

Collapse
 
rd273001 profile image
Ravi Dubey

how to do that? is it like this -
Image description

Collapse
 
rd273001 profile image
Ravi Dubey

Image description

Collapse
 
ankushb223 profile image
Ankush Banerjee

Thanks bruh!! , works like a charm :)

Collapse
 
kemkartanya profile image
Tanya Kemkar

best article!!

Collapse
 
whosmudassir profile image
Mudassir Khan

Got this error , when deployed the server side code
{"error":"Endpoint not found"}
Here's the link : notable-app-new.onrender.com/
Here's the code: github.com/whosmudassir/mern-app-t...

Collapse
 
jonathanmedhed profile image
Jonathanmedhed

I get this error on deployment of the backend:

cd backend && node app.js

Nov 5 02:18:35 PM

Nov 5 02:18:37 PM /opt/render/project/src/backend/node_modules/bson/lib/bson.cjs:479
Nov 5 02:18:37 PM inspect ??= defaultInspect;
Nov 5 02:18:37 PM ^^^
Nov 5 02:18:37 PM

Nov 5 02:18:37 PM SyntaxError: Unexpected token '??='
Nov 5 02:18:37 PM at wrapSafe (internal/modules/cjs/loader.js:984:16)

Collapse
 
dan0001 profile image
Daniel King

Hi! I recently finished my first MERN project using the create-react-app method above, which has now been depreciated. How would you suggest starting a new MERN project without create-react-app? The current documentation suggests using Next.js, but I'd like to avoid learning another framework until I am comfortable with using the MERN stack. Thanks in advance!

Collapse
 
rd273001 profile image
Ravi Dubey • Edited

Your blog is good, but this basic Setup is almost covered by everyone who shares, please go beyond this basic initital MERN stack deployment, its a request. If you really want to post somehting great then post a blog for having some endpoints, having authentication and authorization, middlewares included, because api endpoints does not work properly or completley for most of the people learning and trying, beyond the initial routes '/' or base url! Please post on this having configurations and setup needed for correctly accessing all endpoints on deployed url. Please do post a blog for this. AND as CRA is deprecated so please post it using Vite React JavaScript if possible.

Collapse
 
souravsk_08 profile image
Sourav Khandekar • Edited

Website deployed successfully but data is not able to get or post. How to fix it?

Collapse
 
kunalukey profile image
Kunal Ukey

Maybe you haven't configured your frontend to request the backend.

Collapse
 
souravsk_08 profile image
Sourav Khandekar

Thankyou for replying, Can you please check the repo github.com/Sourav928/Maadhyam-Bloging.
Any Changes please let me know.

Collapse
 
sylviec profile image
Ise goria

Thank you sooooooo much for this helpful tutorial ! :)

Collapse
 
patelvaibhavcs2223116 profile image
Vaibhav Patel

Thank you for this guide helped a lot

Collapse
 
krishnanunni24 profile image
Krishnanunni S

does the location matters, India is not shown as an option. does that cause any trouble ? should i use a vpn to access after hosting?

Collapse
 
kunalukey profile image
Kunal Ukey

Not really

Collapse
 
ajanur_rahman_2d1b8540ea7 profile image
Ajanur Rahman

After this how can i run or how can i get the frontned in live site

Collapse
 
rishi_agrahari_38ae9b2ddc profile image
Rishi Agrahari

Thank you, Its really helpful