IONIC, Access-Control-Allow-Origin

前端 未结 1 1854
日久生厌
日久生厌 2020-12-19 20:41

I try to send http request with $http (angular) with this code:

$http({
              method: \'GET\',
              url: \'http://192.168.0.17:9000\',
              


        
相关标签:
1条回答
  • 2020-12-19 20:47

    You see this error due to a security mechanism implemented in your browser, called Same Origin Policy.

    Basically, it is caused since your webpage tries to access a resource which resides on a server that is on a different Host, Port or Scheme (HTTP / HTTPS / file etc) than the webpage itself.

    In order to solve this issue, you can do one of the following:

    • Serve your Webpage from the server that you are trying to access. If your webpage URL will be http://192.168.0.17:9000/X.html, your request should be successful and the error will disappear.
    • Add a special header to the response sent from your server, called Access-Control-Allow-Origin.

    Read more here: https://en.wikipedia.org/wiki/Same-origin_policy https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

    0 讨论(0)
提交回复
热议问题