Axios cross-domain problem

is very distressing, and everything that has been rewritten has been written. It has always been localhost

.

another project has also been restarted

main.js

created() {
    let url = this.HOST + "/query";
    this.$axios.get(url, {
      params:{
        type: "yunda",
        postid: 3916090104344
      }
    })
    .then(res => {
      console.log(res);
    })
    .catch(error => {
      console.log(error)
    })

  }
Feb.28,2021

1. This is not a cross-domain problem. You enable the http-proxy component to delegate your request to the domain name http://www.kuaidi100.com. What you see in the browser is localhost, but you actually visit http://www.kuaidi100.com
2.. As for why it is 404, one case is that there is no corresponding interface in the background, and the other is that pathRewrite is not configured correctly


api should be written as / api, because you want to represent / api

proxyTable: {
  '/api':{
    target:'http://www.kuaidi100.com',
    changeOrigin:true,
    pathRewrite:{
      '^/api':''
    }
  }
},
Menu