我试着收集数据并将其发送到服务器,但是,
当我尝试发布JSON.stringify(json数组)时,在服务器端我没有得到发布。
如果im只发送json数组,那么im就会得到帖子(无法解析它)。
var blob= new Blob([makeData(performance.getEntriesByType("resource"),getGuid(),getClientIP())], {type : 'application/json'});
navigator.sendBeacon("https://stage.bitsngo.com/rum",blob);我找了很久才找到答案,试着用cors...例如:
var customParser = bodyParser.json({type: function(req) {
return req.headers['Content-Type'] === '*/*; charset=UTF-8';
}});
app.post('/rum', customParser, function(req, res){
console.log(req.body);
console.log(JSON.parse(req.body));
ramData.addData(JSON.parse(req.body), function (err, res) {});
});有什么帮助吗?
发布于 2020-04-16 02:44:51
sendBeacon内容类型被临时禁用-未捕获DOMException:无法使用类型不是任何CORS的Blob对“”Navigator“”执行“”sendBeacon“”:sendBeacon() -内容类型请求标头的安全列表值被临时禁用。“”详情请参见http://crbug.com/490015。
https://stackoverflow.com/questions/44668707
复制相似问题