Error 503 "No 'Access-Control-Allow-Origin' header"

Asked

Viewed 1,040 times

2

I am trying to make a connection in datasnap using ajax

my code:

                var url = 'http://cloud.nooven.com.br:12345/datasnap/rest/TServerMethods1/CriaSessao/'+cpfCnpj+'|'+usuario+'|'+senha;
                console.log(url);
                $.ajax({
                    type: "GET",
                    url: url,
                    dataType: "json",
                    success: function(data){
                        console.log('sucesso');
                    },
                    error: function(data){
                        console.log('erro');
                    }
                });

the page .html that I’m accessing on the server, so it’s like localhost on the variable url, the error that occurs is this:

XMLHttpRequest cannot load http://cloud.nooven.com.br:12345/datasnap/rest/TServerMethods1/CriaSessao/68243096000152%7CMOACIR%7C123456. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://cloud.nooven.com.br' is therefore not allowed access. The response had HTTP status code 503.

thank you.

  • where I’m using @Guilhermenascimento ???

  • ah, I just used, no big deal, I switched from jsonp to json and changed the error: 'Xmlhttprequest cannot load http://cloud.nooven.com.br:12345/datasnap/Rest/Tservermethods1/Creationsare/68243096000152%7CMOACIR%7C123456. No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://cloud.nooven.com.br' is therefore not allowed access. The Response had HTTP status code 503. '

  • in php, I solved with header( "Allow - ......

  • yes, a lodging of mine

  • the code is in Delphi, is a datasnap

  • I usually solve like this: https://answall.com/questions/92269/qual-%C3%A9-o-nome-opera%C3%A7%C3%A3o-quando-fazemos-uma-requisi%C3%A7%C3%A3o-ajax-para-o-servidor-int

Show 1 more comment

1 answer

1


As per this link CORS on Datasnap REST Server you should wear it like this:

procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
  //Permite requisições de diferentes dominios
  Response.SetCustomHeader('Access-Control-Allow-Origin','*');
  if FServerFunctionInvokerAction <> nil then
    FServerFunctionInvokerAction.Enabled := AllowServerFunctionInvoker;
end;
  • I put it on Delphi, but it still has the same error :( 'Xmlhttprequest cannot load http://cloud.nooven.com.br:3715/datasnap/Rest/Tservermethods1/Creationsare/68243096000152%7CMOACIR%7C123456. No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://cloud.nooven.com.br' is therefore not allowed access.'

  • @Furlan I have no knowledge of such technology, but I will Suport two things. Either you didn’t restart the app or you randomly placed the code anywhere. Since I don’t have your original code, I have no idea where to specify the location to add the method. If you can add details to the question

Browser other questions tagged

You are not signed in. Login or sign up in order to post.