节点js / Angular js – 小心:临时标题显示
这是我的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. '); });
这是我的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'); });
我只是调用POST本地主机:3000 / auth /注册从Angular到Node,但我得到**CAUTION : Provisional headers are shown.**
在Chrome控制台**CAUTION : Provisional headers are shown.**
。
Chrome(小心):
Firefox(NO RESPONSE约30/60秒,然后alert()出现:/):
这可能是什么?
如果我使用GET一切正常,只是与POST,我得到麻烦怎么可能?
personaly我在angular度上使用这个“重置”方法:
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 = {}; }]);
这是固定的2014年3月28日,所以它可以在下一个版本的Crome(V35)
铬社区