Saturday, January 30, 2016

How To Enable Cross-Origin Resource Sharing


.
Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the resource originated. (wikipedia)

We can set a website to allow CORS by writing Header specification in .htaccess file (available on Apache server.

Refer this tutorial to set the Header Specification that enables CORS.
.
Besides that, we can also add the following codes into the PHP script that we are sending request to.

<?php
header("Access-Control-Allow-Origin: *");
...

No comments:

Post a Comment

Labels