简体   繁体   中英

How to make Cross Domain Request to an API from Javascript Client when I don't have access to modify the other domain API?

I have a scenario where I need to fetch JSON response data from an API in a different domain. Lets say the requesting domain is ClientDomain and the API domain in APIDomain.

Now I know that this can be achieved using Access-Control-Allow-Origin header in the API server and then using a client ajax marking the CrossDomain attribute as true, etc.

All my search leads either to modify the API settings to add the Access-Control-Allow-Origin header or do a proxy coding in backend server code. But in my case, I don't have access to the API code and I can't change anything there. I'm able to do a proxy read from C# controller code and fetch data from the APIDomain. I want to know how this can be achieved only with Javascript/Jquery in my current scenario.

Edit: Is there a way to do proxy-ing via Javascript/Jquery?

Any help would be great!

Make an API/page on ClientDomain and access it via Javascript/Jquery. In that API/page call the API on APIDomain and return its data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM