Request doesn't pass access control check: No 'Access-Control-Allow-Origin'

前端 未结 2 1352
遥遥无期
遥遥无期 2021-01-22 01:23

I am just trying to use mocky.io from my http://localhost:8080

But getting this error:

XMLHttpRequest cannot load http:/

相关标签:
2条回答
  • 2021-01-22 01:35

    Actually you should setup the header Access-Control-Allow-Origin in mocky.io. Just click on "Switch to Advanced mode" and you will see a "custom headers" input. Add Access-Control-Allow-Origin and put * as its value. Then create your mocky.io url. It should work now.

    0 讨论(0)
  • 2021-01-22 01:41

    It is looks like you are trying to access to other domain. Maybe add this in the web.config?

    <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="http://localhost" />   </customHeaders> </httpProtocol>
    
    0 讨论(0)
提交回复
热议问题