且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

飞行前响应中Access-Control-Allow-Headers不允许请求标头字段Pragma

更新时间:2022-01-18 21:24:54

如果可以在服务器端进行配置以接受这些标头,则可以.否则,您应该删除那些在$ httpProvider.defaulsts中设置的标头.检查以下代码:

If you can configure in server side to accept those headers, then it's fine. Else, you should remove those header which is set in $httpProvider.defaulsts. Check the code below:

var data = {}
var httpCoonfig = {
    headers: {'Pragma': undefined, 'Cache-Control': undefined, 'X-Requested-With': undefined, 'If-Modified-Since': undefined}
};
$http.post('https://www.google.com/', data, httpCoonfig).then(function(response){
// console.log(response)
}, function(response){
     console.log(response)
});