Home > front end >  Node. Js wrote cors cross-domain, but other IP request failure or timeout
Node. Js wrote cors cross-domain, but other IP request failure or timeout

Time:10-28

# js
Var HTTP=the require (" HTTP ");
Var the querystring=the require (" the querystring ");

HTTP. CreateServer (function (the req, res) {
Res. SetHeader (" Access - Control - Allow - Origin ", "*");
Res. SetHeader (" Access - Control - Allow - Headers ", "X - Requested - With");
Res. SetHeader (" Access - Control - Allow - the Methods ", "PUT, POST, GET, DELETE, the OPTIONS");
Res. SetHeader (' Access - Contral - Credentials, true)
Res. SetHeader (" Access - Control - Allow - Headers ", "the content-type, Content - length, Authorzation, Accept, X - Requested - With");
Res. SetHeader (" X - Powered By ", '3.2.1);
Res. SetHeader (" the content-type ", "text/plain")
The console. The log (the req. Url)
Var getDatahttps://bbs.csdn.net/topics/=';
If (the req. Url) {
The req. On (' data ', function (postDataChunk) {
GetData +=postDataChunk;
})

The req. On (' end ', function () {
The console. The log (getData)
Res. End (getData)
})
}
}), listen (8888, function () {
The console. The log (" open the server ");
});

Other IP request #
  •  Tags:  
  • Ajax
  • Related