Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
522 views
in Technique[技术] by (71.8m points)

vue axios 设置proxyTable跨域后访问接口404

config/index.js

proxyTable: {
      '/api': {
            target: 'http://10.110.148.59:8085',
            changeOrigin: true, 
            pathRewrite: {
              '^/api': '' 
              }
          }
    },

请求接口

this.$http.post('/api/lasf-mgr/user/ylogin',params).then((res)=>{
})

浏览器报错
1592280854178.jpg

请问怎么配置


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

导致这个问题最常见的是pathRewrite,这里的/api到底需不需要重写要看后端接口是否带有/api,如果带有/api,那么是不需要重写为空的

检查下后端接口吧


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...