Reputation: 399
I have a single page applications that needs to call a variety of web services and/or APIs. I would like to understand what is a generally agreed approach to making api or service calls from SPA. We currently have two approaches
For certain 3rd party APIs- we make direct calls from the single page application without a server side proxy. In order for this to work we have CORS enabled.
For other API calls - we make calls to a proxy (wrapper) which is responsible for redirecting them to the appropriate endpoints.
The way we decide which approach to use is - if there is some kind of data manipulation thats needed before calling the 3rd party api - we use the proxy - else we make direct calls from the SPA. Is this a valid approach. Would you have any feedback on if the 1st approach is robust from a security point of view? In the 1st approach we have a http-only cookie that is being used as an access token to make calls to the 3rd party api. Does this make the API we are exposing vulnerable?
thanks in advance
Upvotes: 1
Views: 1455
Reputation: 4972
I highly recommend that you proxify all your API calls.
Calling a 3rd party API is ok for some use cases, but not if you start having to deal with a lot of them.
Here are my key points:
Upvotes: 5