Home > Delphi > CORS for Indy

CORS for Indy

August 8, 2012

If you are using Indy as your server component and want to support CORS, which is quite essential these days with regards to AJAX callback to your server, all you need to do is to add the magic header:

   with aResponseInfo do
   CustomHeaders.AddValue('Access-Control-Allow-Origin','*');

The above basically says “allow all cross domain calls”. If you want to be more specific you can return a comma separated list of allowed domain referrers. Here is a screenshot from Fiddler that shows the headers from the Indy server inside Smart Mobile Studio:

Headers galore

Headers galore

For an interesting read on CORS, check out this NCZOnline article. Also check out this section from HTML5 Rocks if you are a Smart Mobile developer!

Advertisements
%d bloggers like this: