节点js/Angular js - 注意:显示临时标头

its*_*sme 5 javascript xmlhttprequest http-headers node.js angularjs

这是我的Angular js片段代码:

$http({
                method:'POST',
                withCredential:true,
                url:$scope.config.app_ws+'auth/signup',
                data:{user:$scope.auth}
            }).success(function(status, response){

                console.log(response);
            }).error(function(status, response){
                alert(response+'Bummer :( , an error occured plese retry later. ');
            });
Run Code Online (Sandbox Code Playgroud)

这是我的Node.js片段后端:

 var allow_cross_domain= function(req, res, next) {
      res.header('X-Powered-By', 'hey.heyssssssss.org');

      var oneof = false;
      if(req.headers.origin) {
        res.header('Access-Control-Allow-Origin', req.headers.origin);
        oneof = true;
      }
      if(req.headers['access-control-request-method']) {
        res.header('Access-Control-Allow-Methods', req.headers['access-control-request-method']);
        oneof = true;
      }
      if(req.headers['access-control-request-headers']) {
        res.header('Access-Control-Allow-Headers', req.headers['access-control-request-headers']);
        oneof = true;
      }
      if(oneof) {
        res.header('Access-Control-Max-Age', 60 * 60 * 24 * 365);
      }
    // intercept OPTIONS method
    if (oneof && req.method == 'OPTIONS') {
      res.send(200);
    } else {
      next();
    }
    }

    app.use(allow_cross_domain);

    app.post('/auth/signup', function (req, res) { res.send('wtff'); });
Run Code Online (Sandbox Code Playgroud)

我只是从Angular到Node调用POST localhost:3000/auth/signup,但我进入**CAUTION : Provisional headers are shown.**了chrome控制台.

Chrome(注意):

在此输入图像描述

Firefox(没有响应约30/60秒,然后警报()出现:/):

在此输入图像描述

这可能是什么?

如果我使用GET,一切都还可以,只是通过POST我会遇到麻烦这怎么可能?

Got*_*dia 10

personaly我在角度使用这个"重置"方法:

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 = {};
}]);
Run Code Online (Sandbox Code Playgroud)