nodeJs express允许跨域代码

来源:互联网 发布:c语言经典小游戏编程 编辑:程序博客网 时间:2024/06/08 07:33

express配置允许跨域请求

app.all('*', function (req, res, next) {  res.header('Access-Control-Allow-Origin', '*')  res.header('Access-Control-Allow-Headers', 'Content-Type,Content-Length, Authorization, Accept,X-Requested-With')  res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS')  res.header('X-Powered-By', ' 3.2.1')  next()})
原创粉丝点击