我们无法在飞行前与 cors 合作:非常感谢任何帮助
========== 错误============================
About to connect() to localhost port 3000 (#0)
* Trying ::1...
* Adding handle: conn: 0x9d834e8
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x9d834e8) send_pipe: 1, recv_pipe: 0
* Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
======== 卷曲 ============================
# **** note **** is local....
curl -i -X OPTIONS -H "Access-Control-Request-Method: POST" http://****:3000/api/account
-d '{"accountname":"test","organization":"test"}' -H "Content-Type: application/json"
-H "Origin: http://****:8000" -H "Access-Control-Request-Headers: X-Requested-With"
--verbose
========= 恢复代码 ===================
var restify = require('restify');
var server = restify.createServer();
var preflight = require('se7ensky-restify-preflight');
preflight(server);
server.post('/api/account', function(req,res,next) {
console.log("inside account post function");
console.log("req body " + JSON.stringify(req.body));
if (!req.body) {
response.statusCode = 400;
return res.send("Missing or Invalid Params");
} else {
res.send('hello ');
}
});
server.listen(3000, function() {
console.log('%s listening at %s', server.name, server.url);
});