CORS express not working predictably

前端 未结 6 1026
灰色年华
灰色年华 2021-02-08 08:15

I am trying to allow access from everywhere.

I have tried using app middleware:

app.use(function (req, res, next) {
  res.setHeader(\"Access-Control-Allo         


        
6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-08 08:56

    After applying "cors" middleware. You should be passed "http://" before "localhost:". in url send to by Axios like this:

    axios.get("http://localhost:8080/api/getData")
    .then(function (response) {
    this.items= response.data;
    }).catch(function (error) {
    console.log(error)
    });
    

提交回复
热议问题