uni-app 跨域问题解决

[email protected]

一、uni-app 中 manifest.json文件修改,增加h5节点

uni-app 跨域问题解决

 

"h5" : {

        "devServer" : {

            "https" : false,

            "port" : 8080,

"proxy" : {

"/apis" : {

"target" : "http://api.heclouds.com",

"changeOrigin" : true,

"secure" : false,

"pathRewrite" : {

"^/apis" : ""

}

}

}

 

        }

}

 

二、应用调用修改 https://api.heclouds.com 改为/apis

uni.request({

   //   url: "https://api.heclouds.com/devices",

  url: "/apis/devices",

      header: {

        "api-key": "********"

      },

      data: {

 

      },

      success(res) {

        console.log(res)

       

      },

      fail(res) {

        console.log("请求失败")

      }

    })

相关文章:

  • 2022-12-23
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
  • 2021-04-19
猜你喜欢
  • 2022-12-23
  • 2022-01-12
  • 2021-07-15
  • 2021-08-18
  • 2022-12-23
  • 2021-08-31
相关资源
相似解决方案