vue config.js proxy 代理使用记录

vue config.js proxy 代理使用记录

访问开发环境:

proxy: {
  // detail: https://cli.vuejs.org/config/#devserver-proxy
  [process.env.VUE_APP_BASE_API]: {
 	 target: `http://192.168.2.37:8084`,
    changeOrigin: true,
    logLevel:'debug',   //显示代理后的地址
    pathRewrite: {
      ['^' + process.env.VUE_APP_BASE_API]: '' ;  
    }
  }
},

访问线上环境:

proxy: {
  // detail: https://cli.vuejs.org/config/#devserver-proxy
  [process.env.VUE_APP_BASE_API]: {
    target: prodURL, 
    changeOrigin: true,
    logLevel:'debug',  
    pathRewrite: {
      ['^' + process.env.VUE_APP_BASE_API]: '/prod-api' ; //将本地环境变量改为线上 
    }
  }
},

查看代理后的真实请求地址

查看代理后的真实请求地址
过程中想查看代理后的真实请求地址确定代理是否正确,但是目前只找到proxy中加入 logLevel:‘debug’,的方法&#x

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
vue.config.js中,proxy用于配置代理。通过配置proxy,可以将请求转发到指定的目标地址。在引用\[1\]中的示例中,proxy配置了两个代理。第一个代理将以/api/开头的请求转发到http://localhost:8060,第二个代理将以/apis开头的请求转发到https://example.com。在引用\[2\]中的示例中,proxy配置了两个代理。第一个代理将以/v1开头的请求转发到https://monitor-api.xxx,第二个代理将以/(d|api|login|public)/开头的请求转发到https://monitor-third-pard-api.xxx。在引用\[3\]中的示例中,proxy配置了一个代理,将以/chc-shop开头的请求转发到https://www.zhbbroker.cn。这样配置代理可以实现在开发环境中解决跨域问题,将请求转发到指定的目标地址。 #### 引用[.reference_title] - *1* [vue.config.js中配置proxy代理https](https://blog.csdn.net/hbiao68/article/details/121718528)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [[vue]vue.config.jsproxy代理配置](https://blog.csdn.net/tjj3027/article/details/124042186)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [vue.config.js配置proxy代理解决跨越;proxy代理报404;](https://blog.csdn.net/i_am_a_div/article/details/127517818)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值