Jump to content

Rafael Mattos

Members
  • Content Count

    10
  • Joined

  • Last visited

Posts posted by Rafael Mattos


  1. @Andrea Magni

     

    Thank you very much!

     

    I solved the problem with your answer.

     

    Moments before I see your answer, I discovered that the browser sends an OPTIONS before every request to know if the server accepts.
    I in my ignorance had created an OPTIONS method on the server, returning an empty array and with CORS in the header, with the same url for each method (GET, PUT, ...) and had "solved" the problem.

     

    I hope this post helps the beginners, as it helped this beginner.

     

    Thank you!

    • Like 1

  2. Thanks for the reply @Andrea Magni,

     

    Maybe this question has nothing to do with the framework, but as it has more experienced professionals here. I ask the question: What is missing?

     

    I changed the .ini file as you mentioned, but I still get this error in the browser (Access to fetch at 'http://999.999.999.999:99/rest/propu/agent/Orders' from origin 'http://abcd.com' has been blocked by CORS policy: Response to preflight request does not pass access control check: It does not have HTTP ok status.).

     

    I make the same request in postman and I get the answer correctly and in the header I receive

    (Connection → close
    Content-Type → application / json
    Content-Length
    Date Mon, 15 Apr 2019 11:40:30 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)


    I thank you for your help.


  3. Hello!

    I am starting to integrate an application that is on the web but the connection to the service is refused. I read something about the CORS mode ...

    Is correct?

    FEngine.Parameters.Values['CORS.Enabled']:= True;
    
    FEngine.Parameters.Values['CORS.Enabled']:= 'True';

    Thank you!


  4. Hi, how are you?

    I have a get method with the return of a TJSONArray and that object is not destroyed. And when I destroy at the end of the function and raised an exception.

    How do I release this object from memory?

    Thanks in advance.

     

    type 
      [Path('product')]
      TProductResource = class
        protected
        [Context] Token: TMARSToken;
      public
        [GET, PermiteAll]
        function GetProduct([FormParam] ClientId: Integer):TJSONArray;
      end;
    
    function TProductResource.GetProduct(ClientId: Integer): TJSONArray;
    var
      xJSONArray: TJSONArray;
    begin
      try
        if Token.Roles[0] = 'client' then
          xJSONArray:= TBllProduct.Singlenton.RetrieveJSONArray(Token.Claims['Id'].AsInteger)
        else
          xJSONArray:= TBllProduct.Singlenton.RetrieveJSONArray(ClientId, Token.Claims['Id'].AsInteger);
    	Result:= xJSONArray;
      finally
    	//FreeAndNil(xJSONArray); 
      end;
    end;

     

×