after accessing the node server across domains, the post request becomes the options, setting request header, and the data submitted by the post request cannot be obtained
var http = require ("http");
var url = require ("url");
http.createServer(function (req, res) {
var urlObj = url.parse(req.url);
var pathname = urlObj.pathname;
// nodejs favicon.ico
if (!pathname.indexOf("/favicon.ico")) {
return;
};
let requestM=req.method;
res.writeHeader(200,{
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET, POST, PUT, DELETE, OPTIONS",
"access-control-allow-headers": "Content-Type,Content-Length, Authorization, Accept,X-Requested-With",
"access-control-max-age": 10,
"Content-Type": "application/json"
});
if(requestM==="POST"){
var post = "";
// reqdatapost
req.on("data", function(chunk){
post += chunk;
});
}
//post
}).listen(3000);