美文网首页
Express 跨域设置

Express 跨域设置

作者: 大地母亲忽悠着你 | 来源:发表于2018-01-11 14:02 被阅读0次
    app.use((req, res, next) => {
    res.header("Access-Control-Allow-Origin", "*");
    res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
    res.header("Access-Control-Allow-Headers",
      "Content-Type,Content-Length, Authorization, Accept,X-Requested-With,Access-Control-Allow-Origin");
    if (req.method === 'OPTIONS') {
      res.sendStatus(200)
    }else{
      next()
      }
    })

    相关文章

      网友评论

          本文标题:Express 跨域设置

          本文链接:https://www.haomeiwen.com/subject/yggznxtx.html