The most powerful thing today is 'INFORMATION' and technology is the carrier of all this to all of us...
This simply means TECHNOLOGY is the most important thing today...
so here I will make post primarily about technical help, my current (own)work & of course cutting edge tech issues...
So stay tuned...!

Tuesday, April 24, 2012

Implementing HTML5 CORS on the server.

Hi all, I am here once again with some small hack for you all.

You, as a web developer, might have sometime come across a point where you might have needed to fetch some resources from a server with a different domain name as that of others.

You might have resorted to implementing proxy or resorted to a hack called JSONP.

Now, theres no need to take all that hassel, The goodness of Html5 has brought to you something called CORS(Cross Origin Resource Sharing.)

But there is 1 downside to CORS
1. You need to have control over the server, but thats not a big deal, you need to have JSONP enabled on server either when using JSONP, same for proxy, you have to have something on server.

thats ok for now, I have seen many people who work with multiple domains and all of them have been under their own ownership. Like we have at my workplace.

ok, getting back to CORS now, heres what you need to implement on the server side, in order to get it working.

Putting '*' as the value of the header will allow any origin to make a call to your domain from withing a CORS supporting browser. If you want to restrict the domains which can make a CORS call, separate them by comma, like this.

1 comment:

We're a group of volunteers and opening a new scheme in our community. Your site offered us with valuable information to work on. You have done a formidable job and our entire community will be grateful to you.