Cross-Origin Resource Sharing (CORS) is a specification that allows you to implement cross-domain request (ie. use an AJAX resource from another domain). The spec defines a set of headers that allow the browser and server to communicate about which request are (and are not) allowed. It isn't that hard and its supported by all browsers (it even works on IE8, which is down-right surprising).
For example, Adding CORS on an Apache server is just:
headtroll@trollmachine:/# a2enmod headers
And then to expose the header, you simply add the following to your Apache .conf file:
Header set Access-Control-Allow-Origin "*"
More details here.
As for the client side, HTML5Rocks.com already has a tutorial on how to use CORS.
No comments:
Post a Comment