1

How to separately host the backend and the frontend ???

I have express API repository which is currently hosted in Heroku along with its documentation site written in ejs.

But now I'm planning on separating the docs website with gatsby and moving it into another repo and hosting it on netlify while the API service still remains in Heroku.

Here is the end goal :
"/" : the docs website.(netlify)
"/api" : the API services.(heroku)

Can someone help me with how to implement this in the actual application?

Comments
  • 2
    I’d recommend keeping to one repo and containerising the frontend, docs site and backend.

    Use the nginx base image so that you can serve the frontend and docs site from whichever url patterns you want and register the backend as an upstream server.
  • 0
    @LiterallyJesus sounds cool. But the reason behind me wanting to separate it into two branches is for easy and minimal maintenance. Here is a perfect example of what I wanna achieve. His both repos are separate; "/api" serves from the backend and "/" is the frontend docs hosted in netlify.

    example:
    https://github.com/afuh/...
    https://github.com/afuh/...
  • 0
    Front it with a gateway or reverse proxy.
Add Comment