Question

I need to make an ajax call to an external server. To do this I set up a proxy server.

Do I have to host my assets (index.html, ..) on my proxy server or can I use a 2nd server and let that server connect with the proxy.

I suspect that this again would give a cross domain problem? What are my general options regarding this problem?

Was it helpful?

Solution

There are three basic ways to avoid the same origin policy.

Have the HTML document and the Ajax resource on the same origin

In this case the answer is "yes" as far as index.html is concerned, and no for everything else.

Use CORS

In this case, the proxy must add suitable CORS headers and then the answer is "no".

Use JSONP

In this case, the proxy must reexpress the data using the JSONP format and then the answer is "no".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top