解决跨域,proxy代理拦截

小程序里不存在跨域,但是如果是H5的项目存在跨域:

根目录下创建 vue.config.js:

module.exports = {
  devServer: {
    proxy: {
      '/api': {
        target: 'http://localhost:7788',
        ws: true,
        changeOrigin: true,
        pathRewirte:{ //路径重写
             '^/api':''
         }
      },
      '/foo':{
          target:'http://localhost:3001'
        
      }
    }
  }
}

猜你喜欢

转载自blog.csdn.net/qq_46376192/article/details/129178566
今日推荐