XMLHttpRequest cannot load and Response for preflight has invalid HTTP status code 405

前端 未结 3 1717
长情又很酷
长情又很酷 2020-12-03 15:05

I am using ionic framework and angularjs I use chrome for viewing my logs but here i am doing a login page I am trying to post the user entered data to serve but i am gettin

相关标签:
3条回答
  • 2020-12-03 15:09

    If you're using chrome, get "Allow-Control-Allow-Origin" plugin. This will let you ignore all CORS errors.

    It works on mobile because ionic has a cordova plugin "cordova-plugin-whitelist". In your "config.xml" you'll see the line by default, that means your app can access any URL.

    Unfortunately when testing through the browser the cordova plugin is not active.

    0 讨论(0)
  • 2020-12-03 15:13

    For iOS devices, also check the protocol used. Using HTTPS instead of HTTP solved the issue for me.

    0 讨论(0)
  • 2020-12-03 15:30

    CORS actually specifies that two requests should be made to the server on an AJAX call (if certain conditions apply, like sending custom headers).

    The first request (the one with the OPTIONS method) is called pre-flight and is used to check if it's safe to send the full request to the server. The response from the server should contain a valid Access-Control-Allow-Origin header containing the URL of the client or *.

    Your server (and not the client) is the one that needs to support CORS. It seems you are using .Net for it, so you may want to take a look here on how configure IIS.

    You can read more about CORS here.

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