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

module.exports = {
devServer: {
proxy: {
//配置跨域
'/api': {
//这里是真实的后台接口
target: 'https://localhost:5001/',
//允许跨域
changeOrigin: true,
//重写路径
pathRewrite: {
/*
浏览器中看到请求的地址为:http://localhost:8080/api/region
实际上访问的地址是:https://localhost:5001/api/region
如果请求中不存在/api则设置为'^/api': '',
*/
'^/api': '/api',
},
},
},
},
}
设置为'^/api': ''所有的请求中如果不是/api/开始的请求也需要写上会自动替换成后边的值

配置完成后需要重新启动vue项目

最新文章

  1. webapi的学习资料
  2. 常见ES6新属性
  3. 原始感知机入门——python3实现
  4. 共享业务稳定性测试&技术创新组
  5. ackerman递归
  6. android stuido 在线安装svn插件,添加版本库无响应
  7. [转]Android重力感应开发
  8. 11gOCP 1z0-052 :2013-09-11 MGR_ROLE role........................................................A66
  9. 第二次项目冲刺(Beta阶段)5.25
  10. Git基本命令 -- 创建Git项目
  11. vue 双向数据绑定原理
  12. throws与throw
  13. bzoj1741 [Usaco2005 nov]Asteroids 穿越小行星群 最小点覆盖
  14. Liunx 硬盘分区
  15. Centos 7 安装 PostgreSQL PGAdmin4
  16. win7X64位安装mysql-5.7.16
  17. 软件工程课程设计——第一个Spring
  18. Anfroid 在界面中显示图片 ImageView
  19. Hive之 hive架构
  20. 如何修改TFS 2013中工作项附件大小限制

热门文章

  1. Bugku-web-web8
  2. Bypass D盾 Webshell
  3. 【LeetCode】169. 多数元素
  4. VScode安装配置
  5. 去掉文件中的^M
  6. spring-security oauth2.0简单集成
  7. Redis奇怪的姿势
  8. Charles 抓包 Client SSL handshake failed - Remote host closed connection during handshake
  9. 伪静态是什么?伪静态与普通html静态网页区别?
  10. .Net Core WebApi(三)--使用 IdentityServer4 4.1.1 踩坑记录