A
A
Alexey Chernyavskiy2022-04-20 10:27:00
Software design
Alexey Chernyavskiy, 2022-04-20 10:27:00

Is it better to deploy frontend and backend on the same domain or different subdomains?

Interested in the pros and cons of both approaches.
I have a frontend part of a web application (SPA, ReactJS) deployed as a docker container on the myapplication.com domain AND
I have a backend part written in .net core (or java) deployed as a docker container on the api.myapplication.com subdomain

Now there are two software engineers, John and Steven. John says that the way the services are currently deployed is correct. But he cannot justify why this is correct.
And Steven says it's better to have the frontend and backend work on the same domain. (myapplication.com and myapplication.com/api). But he also cannot give convincing arguments why this approach is better.

Question for those in the know. Which approach is "better" and why?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexey Chernyavskiy, 2022-04-21
@pprometey

I liked this answer:
Will the API be used by other services, or is it intended for a front-end (e.g. marketing site, mobile app, third party, etc.).
Both ways can work, but in this case a separate subdomain would separate the issues.
If the back end is application specific, I would leave it in the main domain.

D
Dr. Bacon, 2022-04-20
@bacon

Are there problems now? If not, leave as is. And since no one can justify their point of view, everyone can be sent.

S
Sergey Sokolov, 2022-04-20
@sergiks

being on a single domain, the front and back for no reason are "connected" at least by a common entry point.
If you untie them by placing them on different subdomains, this will allow, for example, only the backing to independently move from server to server; or move the static front to a CDN without touching the back.

R
Romi, 2022-04-20
@romicohen

Yes, vosche pof))
The only thing is that on one domain there is less possible fuss with CORS, but this is so-so, insignificant.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question