Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
恢复cors飞行前未连接_Cors_Restify_Preflight - Fatal编程技术网

恢复cors飞行前未连接

恢复cors飞行前未连接,cors,restify,preflight,Cors,Restify,Preflight,我们无法让restify在飞行前与cors合作:非常感谢任何帮助 ==========错误=========================== ==========卷曲=========================== ============重新验证代码================== 试过这个吗 server.use(restify.CORS()); # **** note **** is local.... curl -i -X OPTIONS -H "Access-Contr

我们无法让restify在飞行前与cors合作:非常感谢任何帮助

==========错误=========================== ==========卷曲=========================== ============重新验证代码================== 试过这个吗

server.use(restify.CORS());
# **** 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);
}); 
server.use(restify.CORS());