Use a separate service for Go based API and React?

I have a Go based API for a React based frontend. Today I mesh everything together and serve the static react part from the “/” route of the API. This however complicates the build a bit as I first have to copy over the react solution and then build the Go part.

Would it be a better solution to have the React front end on a static page service and the API on a separate service do you think? What would be the pro and cons and I’d be very interested in how other structures similar solution.

The biggest reason to separate your application into a service and a static site is to get the CDN for the static site. If you use two different deployments, you will have different hostnames for your two services; is this something that concerns your use case? If you want to deploy both under one service, we include node on all of our build images. So, if you have a running process but also want to build some static assets, you can use that. Going this route, you will just have to make sure you serve the assets somehow (eg via your Go process).

1 Like