Connect a local Restserver

i can't connect to a local Restserver:


TMS WEB Runs on Port 8000, the local REST Server Runs on Port 8089:

 WebClientConnection1.URI :='http://localhost:8089/artikel?2';
 WebClientConnection1.Active:=True;

Error connecting to URI http://localhost:8089/artikel?2 | fMessage::Error connecting to URI http://localhost:8089/artikel?2 fHelpContext::0
at http://localhost:8000/TestDBWeb/TestDBWeb.js


Is the browser console giving more details on the error?

Access to XMLHttpRequest at 'http://localhost:8089/artikel?2' from origin 'http://localhost:8000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.



So, you need to enable CORS on this local server. Because it is on a different port, it is considered from a different origin.

ok, now it works.


4 other user with the same Problem:

  Response.CustomHeaders.Values['Access-Control-Allow-Origin']:='*';
  Response.CustomHeaders.Values['Access-Control-Allow-Methods']:='GET,POST';
  Response.CustomHeaders.Values['Access-Control-Allow-Headers']:='Content-Type, Accept';
  Response.CustomHeaders.Values['Access-Control-Allow-Credentials']:='true';
  Response.ContentType:='application/json; charset=UTF-8';