Vite App, how can I deploy my backend that is in the same folder with my frontend

Hello.

I have created an app with Vite, React, Mongo db and Express. I can host static page just fine but whenever I want to deploy my backend, I get a console error “Loading failed for the module with source “https://sys-ctzx.onrender.com/src/main.jsx”.”

I googled a lot and could not manage to get it to work. Can someone point me towards a direction that I can deply my backend on Render? thanks

Hey there

Do I understand correctly that you are deploying to render services.

  • One static service that is serving your react code that was built with Vite and this works
  • One web service that should run the nodejs/express code.

In that case could you share your setup, e.g what are your build and start commands for those services?

For your static site your build command should be something like npm run build, then you define your publish path e.g. /dist

For your web service (express) your build command could be something like npm ci and start command something like node ./server.js

Bergur