Hi guys,
I have modified the sample application TMAWeb_SimpleService return a list of json filenames from my webservice. Which has
procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
Response.SetCustomHeader('Access-Control-Allow-Origin','*');
end;
procedure TForm1.WebButton1Click(Sender: TObject);
begin
// WebHttpRequest1.URL := 'https://download.tmssoftware.com/tmsweb/music.json';
WebHttpRequest1.URL := 'http://92.27.68.65:7777/getRockVideos';
WebHttpRequest1.Execute();
end;
procedure TForm1.WebHttpRequest1RequestResponse(Sender: TObject;
ARequest: TJSXMLHttpRequestRecord; AResponse: string);
var
js: TJSON;
ja: TJSONArray;
jo: TJSONObject;
i: integer;
begin
js := TJSON.Create;
try
ja := TJSONArray(js.Parse(AResponse));
ShowMessage('Retrieved items:' +AResponse);
for i := 0 to ja.Count - 1 do
begin
jo := TJSONObject(ja.Items[i]);
WebListBox1.Items.Add(jo.GetJSONValue('videoName'));
end;
finally
js.Free;
end;
end ;
end.
This work fine in the sample application.
When I add this code to my application I get a cross domain access error.
rocksTruck.html:1 Access to XMLHttpRequest at 'http://92.27.68.65/getRockVideos' from origin 'http://localhost:8000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I can't see any setting in the sample application that solves the issue.