Angular POST导致原产地'http://evil.com/'不被允许

and*_*dko 3 cors angularjs

我正试图以这种方式POST到WebApi后端:

'use strict';
angular.module('auth', []).factory('authService', ['$http', '$q', '$localStorage', function ($http, $q, $localStorage) {

    var serviceBase = 'http://localhost:53432/api/';
    var authServiceFactory = {};

    var authentication = {
        isAuth: false,
        userName: ""
    };

    var saveRegistration = function (registration) {
        return $http.post(serviceBase + 'account/register', registration).then(function (response) {
            return response;
        });

    };
Run Code Online (Sandbox Code Playgroud)

但我得到错误"message":"The origin 'http://evil.com/' is not allowed." 我明白这与CORS问题有关,所以我在模块中定义$sceDelegateProvider:

$sceDelegateProvider.resourceUrlWhitelist([
    'self',
    'http://localhost:53432' //This is webapi url
        ]);
Run Code Online (Sandbox Code Playgroud)

但这也没有帮助.我该怎么解决这个问题?
在服务器端已启用CORS:

 [AllowAnonymous]
 [Route("Register")]
 [HttpPost]
 [EnableCors(origins: "http://localhost:8080", headers: "*", methods: "*")]
 public async Task<IHttpActionResult> Register(RegisterBindingModel register)
Run Code Online (Sandbox Code Playgroud)

Bau*_*gen 9

这很有趣,但问题是通过关闭浏览器中的CORS插件解决的.


问题解决方案来自andrey.shedko.