Cross-origin resource sharing (CORS) is a mechanism that enables resources to be shared across domains. Typically this isn’t allowed to prevent security issues. To enable on your DataSnap REST server you can use the following code per MVP Nirav Kaku from India.
All you need to do is add a custom header in the Response before dispatching the result on the DataSnap server…
procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject;<br /> Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);<br /> begin<br /> //allows cross domain calls<br /> Response.SetCustomHeader('Access-Control-Allow-Origin','*');<br /> if FServerFunctionInvokerAction <> nil then<br /> FServerFunctionInvokerAction.Enabled := AllowServerFunctionInvoker;<br /> end;
It is useful for DataSnap server developers who want
Note: CORS is security feature of the browser so there could be some
dependency there. Tested with Firefox, Chrome and IE and it seems to
be working fine.