No 'Access-Control-Allow-Origin' header is present on the requested resource- AngularJS

前端 未结 12 1386
有刺的猬
有刺的猬 2020-11-27 03:18
XMLHttpRequest cannot load http://mywebservice. No \'Access-Control-Allow-Origin\' header is present on the requested resource. Origin \'http://localhost:9000\' is t         


        
12条回答
  •  时光取名叫无心
    2020-11-27 04:17

    On the client side you can enable cors requests in AngularJS via

    app.config(['$httpProvider', function($httpProvider) {
            $httpProvider.defaults.useXDomain = true;
            delete $httpProvider.defaults.headers.common['X-Requested-With'];
        }
    ]);
    

    However if this still returns an error, this would imply that the server that you are making the request has to allow CORS request and has to be configured for that.

提交回复
热议问题