DEV Community

Cover image for Render Deployment (free tier) of MERN App

Render Deployment (free tier) of MERN App

Greg on September 08, 2022

A guide to deploying your full stack MERN app to Render Prereqs: Github Account Render Account A fully functional MERN APP and it's re...
Collapse
 
sparezanin profile image
Slavko Parezanin

Hi Greg,
Great tutorial!
I followed steps from this tutorial, but i can't connect /api calls to my express server.
My project is at:
github.com/SlavkoPar/support-mern
Instead of redirection, i added 2 env variables:
REACT_APP_HOST: support-knowledge.onrender.com
REACT_APP_PORT: 4001
so i get a call:
support-knowledge.onrender.com:400...
i even created test call:
support-knowledge.onrender.com:400...
but I always get the response:
net::ERR_CONNECTION_TIMED_OUT
Do you have any suggestion?
Regards!

Collapse
 
sparezanin profile image
Slavko Parezanin

In my Web Service I tried:
curl -X POST 127.0.0.1:4001/api/test
and received the response: 'Welcome to GeeksforGeeks'

Collapse
 
sparezanin profile image
Slavko Parezanin

My site is: support-knowledge.onrender.com/
I found solution for my /api/* calls, setting my Web Service link to ‘Rewrite rules’:

/api/*
support-knowledge-service.onrender...
Rewrite

Best Regards !

Collapse
 
kunalukey profile image
Kunal Ukey

Great guide! 🤝

Collapse
 
bhuwancloud profile image
Bhuwan Bhatt (Bhuppi)

great tutorial

Collapse
 
hnhtran profile image
Tran Huynh • Edited

Hi Greg, if you can give me advice please?
I tested in local host successful..
I have succeeded deployed web service, but cannot deploy static site, it keeps saying

npm ERR! code EINVALIDTYPE
npm ERR! typeerror Error: Argument #5: Expected object but got string
Enter fullscreen mode Exit fullscreen mode

Great appreciation!

Collapse
 
hnhtran profile image
Tran Huynh

Issue resolved! For anyone running into same issue as me, instead of
"render-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
I delete config string, become
"render-postbuild": "npm install --prefix client && npm run build --prefix client"

Collapse
 
opyjo profile image
opyjo

The build Command in the webservice has yarn which does not seem correct. what did you change it to?

Thread Thread
 
hnhtran profile image
Tran Huynh

I still use yarn without any issue opyjo. You had any issue? can post the error, we see together?

Thread Thread
 
gregpetropoulos profile image
Greg

Thanks for the feedback share your repo and errors and I will help debug. The 'yarn' in the build command input box for Web Services is not in use, thus you shouldn't have any issues with that. Essentially I am not building anything from the services(backend server), but you certainly could do it that way. Since my repo has the frontend and backend in one repo when the script render-postbuild is ran it comes from the root folder housing the frontend and backend. I know when the "NPM_CONFIG_PRODUCTION=false this is just a way to set the production to false until the npm run build is compiled then on the NODE_ENV side it will know we are in a production environment.

Hope this helps.

Collapse
 
joniedev profile image
Okoro John

That's great. I've gotten what I am looking for... timely.

Collapse
 
dineshraj100 profile image
Dineshraj • Edited

hello Greg, I need your help in this deployment. I did as you mentioned above. but for some reason my backend is failing to deploy. only thing i changed from your step was in build command. i changed yarn to npm install. help me with this issue please

the error in pic actually shows that concurrently is not found. i even tried to run it with yarn, its showing the same thing. But in my local machine concurrently runs with the same command "npm run dev"

my project github link: githublink

Image description

Collapse
 
dineshraj100 profile image
Dineshraj

ok. I solved this error by adding the dev dependencies inside the dependencies in package.json file. thanks for this guide greg