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