Solve cross-domain, proxy proxy interception

There is no cross-domain in the applet, but if it is an H5 project, there is a cross-domain:

Create vue.config.js in the root directory:

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

Guess you like

Origin blog.csdn.net/qq_46376192/article/details/129178566