VUE local debugging cross-domain problem solving

Vue local debugging solves cross-domain problems

  1. Open the index.js file under the project config folder
  2. Configure proxyTable proxy
proxyTable: {
    
    
      '/api': {
    
    
        target: 'https://xxx.xxx.xxx.xx',  // 接口域名
        changeOrigin: true,  //是否跨域
        secure: false,
        pathRewrite: {
    
    
          '^/api': '' 
        }
      }
    },

Complete effect after configuration
3. Open the dev.env.js file in the Insert picture description here
config directory for configuration 4. Open the dev.prod.env.js in the config directory for configurationInsert picture description here

Guess you like

Origin blog.csdn.net/weixin_42407989/article/details/109579611