Jean Vandromme 0 Posted May 14, 2019 Hi Andrea, I try to decomment the preflight request sample in server.ignition.pas of the WebTemplate demo but got an error: [dcc32 Error] Server.Ignition.pas(80): E2010 Incompatible types: 'TBeforeHandleRequestProc' and 'Procedure' What do I do wrong ? Thanks Jean Vandromme Share this post Link to post
Andrea Magni 75 Posted May 14, 2019 Hi @Jean Vandromme, it is a regression as I changed the argument types of that anonymous method. I fixed the same issue on other demos but I probably missed that one. Please check https://github.com/andrea-magni/MARS/commit/91a3a286d0e789375ec7fa0c8e98b4c7b59b5586 The changes for Server.Ignition.pas are the same you are looking for. Let me know if you can solve this (and if you like, please open a pull request with the fixes!) Thanks Share this post Link to post
Jean Vandromme 0 Posted May 14, 2019 Thanks Andrea but it seems I have to do something more to get rid of a 500 server error. I try to acces the FireDac server demo through an angular frontend. I had first a CORS problem which is now resolved. But now I have a 500 internal error server when a I try a simple get for the employee table. I can access it with Postman without any problem. I add this in the Form.create of server.forms.main.pas: // MARS-Curiosity Engine FEngine := TMARSEngine.Create; try FEngine.Parameters.LoadFromIniFile; FEngine.AddApplication('DefaultApp', '/default', ['Server.*']); PortNumberEdit.Text := FEngine.Port.ToString; TMARSFireDAC.LoadConnectionDefs(FEngine.Parameters, 'FireDAC'); FEngine.BeforeHandleRequest := function (const AEngine: TMARSEngine; const AURL: TMARSURL; const ARequest: IMARSRequest; const AResponse: IMARSResponse; var Handled: Boolean 😞 Boolean begin //Result := True; if SameText(AURL.Document, 'favicon.ico') then begin Result := False; Handled := True; end; // Handle CORS and PreFlight if SameText(ARequest.Method, 'OPTIONS') then begin Handled := True; Result := False; end; Result := True; end; StartServerAction.Execute; except FreeAndNil(FEngine); raise; end; This is the headers response in POSTMAN Connection →close Content-Type →application/json Content-Length →2420 Date →Tue, 14 May 2019 13:25:39 GMT Access-Control-Allow-Origin →* Access-Control-Allow-Methods →HEAD,GET,PUT,POST,DELETE,OPTIONS Access-Control-Allow-Headers →X-Requested-With,Content-Type,Authorization In chrome, I have a 500 internal error server Share this post Link to post