首页 > Web开发 > 详细

nodejs 项目解决浏览器跨域问题。

时间:2015-10-08 20:11:42      阅读:168      评论:0      收藏:0      [点我收藏+]

//设置跨域访问

app.all(‘*‘, function(req, res, next) {

    res.header("Access-Control-Allow-Origin", "*");

    res.header("Access-Control-Allow-Headers", "X-Requested-With");

    res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");

    res.header("X-Powered-By",‘ 3.2.1‘)

    res.header("Content-Type", "application/json;charset=utf-8");

    next();

});


nodejs 项目解决浏览器跨域问题。

原文:http://my.oschina.net/u/2349117/blog/514417

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!