restbridgeclient doesn't do 'GET' lazarus / 76-Pas2JS ---------------------------------------------------------------------- rca · 2024-06-29 05:54 I am working with example restbridgeclient (pasjs demo) and restserver (Lazarus demo) from sqldbrest. When using jsonclient (Lazarus demo) it works OK and the server shows: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i [Resource] (User: ?) Resource: metadata; Operation: GET[Connection] (User: ?) Using connection to Host: localhost; Database: expensetracker[Authentication] (User: me) Authenticated user: me[Result] (User: me) Resource: metadata; Operation: GET; Status: 200; Text: OK However, when using restbridgeclient example (pasjs demo), it doesn't work and the server shows: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i [Result] (User: ?) Resource: metadata; Operation: OPTIONS; Status: 403; Text: FORBIDDEN The difference is in the Operation, it should be 'GET', but it sends 'OPTIONS'. In the unit sqldbrestdataset, there is the "constructor TServiceRequest.Create", if I comment the following line of code Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i FXHR.setRequestHeader('Authorization', 'Basic '+window.btoa(aUserName+':'+aPassword));it sends the 'GET' method, but obviously it would not be authenticated and still does not work. Please can you help me solve it? Thank you ---------------------------------------------------------------------- rca · 2024-07-01 13:57 After finding and reading some information: https://stackoverflow.com/questions/63752007/axios-request-method- changes-to-options-instead-of-get https://stackoverflow.com/questions/21783079/ajax-in-chrome-sending- options-instead-of-get-post-put-delete https://stackoverflow.com/questions/29954037/why-is-an-options- request-sent-and-can-i-disable-it In short, it not only happens with the 'GET' method, it will also happen with 'POST', 'PUT' or 'DELETE'. "OPTIONS request is part of the so-called preflight request which is needed to figure out the CORS headers to know what needs/is allowed to be sent to the server with the actual request." More details about "Cross-Origin Resource Sharing (CORS)" https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS "CORS preflight" https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request So the solution is on the server side (restserver Lazarus demo), within Dispatcher options, enable "rdoHandleCORS" (Handle CORS requests) and that's it! Enjoy!