{$mode objfpc}{$H+}
uses
{$ifdef UNIX}
cthreads, cmem,
{$endif}
fphttpapp, httpdefs, httproute, fpjson, jsonparser;
procedure route1(aReq: TRequest; aResp: TResponse);
var
s:string;
D,E : TJSONData;
begin
writeln(areq.Content);
D:=GetJSON(areq.Content);
E:=d.FindPath('title');
s:=E.AsString;
// aResp.SetStatus(200);
aResp.Content:='<html><body><h1>Route 1 respone:'+s+'</h1></body></html>';
end;
procedure route2(aReq: TRequest; aResp: TResponse);
begin
aResp.Content:='<html><body><h1>Route 2</h1></body></html>';
end;
begin
HTTPRouter.RegisterRoute('/', @route1);
HTTPRouter.RegisterRoute('/2', @route2);
Application.Port := 1999;
Application.Threaded := true;
Application.Initialize;
Application.Run;
end.
when I run this code it is working in postman not working in browser .
I am getting cors isssue .
browse send the preflight request with "options" request .
D:=GetJSON(areq.Content); the content is nil.
getting CORS issue .