Hello,
I want to load my config from a local json file. There are the settings for my rest server.
But I get an 403 error.
See picture.
Here is the code in Delphi:
var
Conn: TXDataWebConnection;
begin
Conn := TXDataWebConnection.Create(nil);
try
Conn.SendRequest(THttpRequest.Create('config/config.json'), THttpResponseProc( @OnSuccess), THttpErrorProc( @OnError));
finally
Conn.Free;
end;
end;
procedure TMainForm.LoadConfig;
var
Request: TWebHTTPRequest; // The request/URL
Response: TJSXMLHttpRequest; // The response coming back
Data: TJSONObject; // The response coming back, as JSON
begin
Request := TWebHTTPRequest.Create;
Request.URL := '...server url from same host.../config.json';
Response := await(TJSXMLHttpRequest,Request.Perform());
Data := TJSONObject.ParseJSONValue(String(Response.Response)) as TJSONObject;
...do something with data...
end;
This assumes that just typing the URL into your browser will load the config file. If it doesn't, you might want to get that sorted out first.
Your server is not responding with any CORS headers, such as access-control-allow-origin. We can't see if it's a problem with CORS because there is no URLs in your screenshots, but your server doesn't look to be configured to support CORS.