AngularJS performs an OPTIONS HTTP request for a cross-origin resource

后端 未结 14 1652
生来不讨喜
生来不讨喜 2020-11-22 03:04

I\'m trying to setup AngularJS to communicate with a cross-origin resource where the asset host which delivers my template files is on a different domain and therefore the X

14条回答
  •  日久生厌
    2020-11-22 03:34

    NOTE: Not sure it works with the latest version of Angular.

    ORIGINAL:

    It's also possible to override the OPTIONS request (was only tested in Chrome):

    app.config(['$httpProvider', function ($httpProvider) {
      //Reset headers to avoid OPTIONS request (aka preflight)
      $httpProvider.defaults.headers.common = {};
      $httpProvider.defaults.headers.post = {};
      $httpProvider.defaults.headers.put = {};
      $httpProvider.defaults.headers.patch = {};
    }]);
    

提交回复
热议问题