-1

I have an Angular webApp. It is served by server #1. And most of its data is pulled from a webservice hosting on the same server (#1).

Now I need to add a new feature which requires me to post to a rest-endpoint on a second server (#2). I have two options:

  • let my front-end UI talk directly to server #2, which requires me to change cross-origin policy, OR
  • add a proxy endpoint on server #1, and let my webapp talk to server #1's proxy endpoint, which in turn talk to server #2's endpoint.

Which way is a converntional way of doing this?

Yuri
  • 4,254
  • 1
  • 29
  • 46
modeller
  • 3,770
  • 3
  • 25
  • 49

1 Answers1

1

You should talk to an API gateway which handles all the backend-related aspects. IMO, CORS should be the last resort.

Yuri
  • 4,254
  • 1
  • 29
  • 46
  • But why it is common practise to download from multiple cdn of js libraries? e.g. jqueries, bootstrap.js, etc – modeller May 07 '19 at 22:09
  • Here's a great CORS explanation https://stackoverflow.com/a/25311247/2178042. And here's another for why using a CDN: https://stackoverflow.com/a/34330741/2178042 – tottomotto May 08 '19 at 08:04