How to deploy separated frontend and backend?
18,667
I just answered a related question for AWS.
You can deploy
-
your frontend on a static hosting service and a CDN
-
your backend on a cloud computing service
You can set different subdomains on different hosts, e.g.
-
app.domain.com
on GitHub Pages -
api.domain.com
on Heroku
Related videos on Youtube
Author by
Yen Sheng
Updated on June 04, 2022Comments
-
Yen Sheng almost 2 years
I am developing a new project with react/express as the frontend and loopback as the backend api. I have separated both of them in my development environment with different ports.
How should I deploy them in production?
Hosting on a same server - separate the backend with a different sub-domain?
Hosting on 2 different servers - seems impossible to use back the same domain.
-
Hansen W about 6 yearsGreat answer, thanks, helped me a lot. Just have an additional question. In this case, how many instances of containers should I use for frontend and backend? I know for the backend since it accepts a lot of incoming requests, a load balancer and several instances should be deployed. But how about frontend, should I use equal amount or just one instance since I already have CDN?
-
GG. about 6 years"just one instance since I already have CDN" - yes just one. It's the CDN's job to make it scale.
-
titus over 4 yearsWhat about CORS and/if using httpOnly cookies?
-
tanguy_k about 4 yearsWhat about SSR (Next.js for example)? Your frontend then needs to run Node.js.
-
Daniel about 3 years@GG., this is a great answer. Any documentation out there on how to get that backend Heroku talking to the frontend on S3 + Cloudfront?
-
Jahir about 3 yearsGood summary. The CORS issue needed some mentions though
-
Olgun Kaya over 2 yearsI don't know why people don't want to use or utilize nginx approach ? Just deploy your frontend on an nginx/httpd etc.. then apply proxies as per your APIs towards related endpoints.
-
GG. over 2 years@OlgunKaya you don't need a web server to serve a static file.