Bypassing the Same-Origin Policy Requirements

When running into issues with the same-origin policy, developers implement some of the following methods to bypass these browser restrictions:

  • Using a server-side proxy script. For instance, your JavaScript file can make a request to some PHP or Python script that it has access to, which in turn can facilitate server-to-server communication to some cross-domain source.

  • Implement a Flash transport layer. In the same way that the server-side proxy works, some developers have used Flash to proxy requests to overcome the limits imposed by the same-origin policy.

  • Generating iframes to pass data from a source site through to another location where the iframe is loaded.

There are numerous other ways to bypass the issue of communication between sites due to the same-origin policy restrictions, but these are a few of the most commonly implemented.

Get Programming Social Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.