Deploy react app using vite

Hi, I’m having issues deploying my full stack react app using vite. I was able to deploy my front end and backend separately. however, I’m not sure how to get them to work together. Or if I should just change my server.js to serve up my app? Any direction or guidance is much appreciated!

Hi there,

You must update your frontend so it calls your backend on its public domain. This might be the onredner.com domain or your custom domain if you are using one. This is likely different to have you developed this as everything would have been running on the localhost.

There is also nothing stopping you from deploying your frontend and backend as one service and then serving the built static assets from your server.js using Express. You will still need to use your onrender.com domain for this. The only advantage with this is that because both your front and backends use the same domain, you don’t need to worry about CORS which can be a pain.

Regards,

Keith
Render Support, UTC+10 :australia:

1 Like

well can you be more specific, i also created and deployed on and it is working fine

I figured it out. The build and run commands were wrong. I was able to deploy front and backend and have my express server serve up my front end. Thanks for your responses.

The error was it could not find vite. As the vite.config.js exists in my client folder. And it was looking for it in the root directory. I was able to change the build commands to run everything in the correct places.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.