Aug 31, 2018 · 1 min read
I’ve found a potential solution! Instead of serving APIs on their own subdomains, setup a reverse proxy and serve the SPA and it’s APIs behind the reverse proxy and use a single domain. So the SPA might be at example.com/ and the reverse proxy serves all the APIs rooted under example.com/api/
That way the SPA could fetch from it’s API using relative URLs: “/api” instead of fully qualified URLs and it would always communicate with the correct domain’s API(s) and I could use the same SPA container image in all environments/URL spaces.
WDYT?
