1

The frontend is a React SPA and the backend is NodeJs app that exposes an API. The frontend queries the API for data from time to time but other than that it is fairly independent. What is the best way to host an app like this? Should I include the build folder in the NodeJs app and have the express server serve the static contents from a route? Or should I host both separately, set up a Nginx server for the React app on something like DO? I will host the backend on something like Heroku or Google App Engine. So considering this, what is the ideal solution? What are the pros and cons of either approach?

1 Answer 1

1

In case of production, include build folder in the nodejs app.
Performance increase in case production. You can refer react docs for details.

In case of development, host it separately, so its easier to work on it.

Sign up to request clarification or add additional context in comments.

2 Comments

I think you have misunderstood my question a bit. I know about the production build, my question is which is the better solution, should I serve the static files from the same web app that is serving the API or should I host a separate a web server that just serves the static files when requested?
Serving the static files from the same web app that is serving the API is the right way. You can check the mern starter code to learn more mern.io

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.