Is the proxy the right way for an external REST Api?

We need to consume external Api REST and dynamically update content on our website and are faced with the age-related problem of cross-site scripting and Ajax.

I read JSONP, but I don’t want to go this route in a million years, as it seems really quite a dirty hack.

How to solve this problem it’s “correct” and “right” to have a local service that acts as a proxy for any requests to external Api? Thus, on the client there would be an Ajax call on ../RestProxy/MakeRequest, passing him the request details, which he must execute for the external api, he executes the request and returns everything that has passed.

Any thoughts would be appreciated.

+3
source share
1 answer

:

1. JSONP

API . JQuery . .

2. Proxy

, . , . , .

3. Access-Control-Allow-Origin

, , json , . jsonp, , , -, .

Access-Control-Allow-Origin :

  • IE8 +
  • Firefox 3.6 +
  • Safari 4.0 +
  • Chrome 6 +
  • iOS Safari 3.2 +
  • Android- 2.1 +

If you need to support IE7, then this option is not for you.

+5
source

All Articles