node.js express 客户端提示需要访问 Rejected because on crossdomain.xml policy file was found.
发布于 11 年前 作者 mrchi 3825 次浏览 最后一次编辑是 8 年前

我用express框架写了一个手机游戏服务器,IOS客户端程序在访问服务端时提示"Rejected because on crossdomain.xml policy file was found." 安卓系统下可以正常访问服务端。求解!!

1 回复

http://enable-cors.org/server_expressjs.html

app.all('/', function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  next();
 });

app.get('/', function(req, res, next) {
  // Handle the get for this route
});

app.post('/', function(req, res, next) {
 // Handle the post for this route
});

參考這個

回到顶部