Im developing a web-based application, using Angular2 as front-end and Django 1.10 as back-end, and Nginx as web-servers interface.
Should Angular2 access the Django API through api.mydomain.com
or mydomain.com/api/
?
I have seen examples of both, and I want to know the pros and cons.
I generally prefer using
api.example.com
instead of a URL path. Doing this allows you to de-couple your web application infrastructure from your API infrastructure. Perhaps they're running on the same server now, but by using a sub-domain, you can easily separate them in the future without requiring major code changes.