当前位置:网站首页>uni-app跨域配置
uni-app跨域配置
2022-07-26 02:14:00 【zjLOVEcyj】
uni-app跨域配置
在项目根路径下新建配置文件 vue.config.js
module.exports = {
devServer:{
port:'8080',
disableHostCheck:true,
proxy:{
'/api':{
target:'https://www.uinav.com/',
changeOrigin:true,
pathRewrite:{
'^/api': '/api'
}
}
}
}
}
- port是浏览器运行端口
- /api 是要配置跨域的接口前缀
- target是要转发的服务器地址,即实际请求的服务器地址
- changeOrigin是是否更换源,如果设置为true的话会把请求header的host替换为target,但是在浏览器F12检查中不会替换,只有在后端服务器上使用request.header才能看到host的替换,浏览器端不会显示替换
- pathRewrite是路径重写,一般会把前端手动添加的区别性剔除掉,如果前端没有使用自己设置的前缀则无需设置
边栏推荐
- Navica工具把远程MySQL导入到本地MySQL数据库
- 国标GB28181协议视频平台EasyGBS消息弹框模式优化
- [pyqt5 packaged as exe]
- Jupiter notebook reported an error: notebook validation failed: non unique cell ID '2a4xx6' detected
- The third question of leetcode 302 weekly Games -- query the number with the smallest k after cutting the number
- Redis集群搭建(基于6.x)
- SQL manual blind injection and error reporting injection
- I came to the library applet check-in process analysis
- c# 单元测试
- Composition API的优势
猜你喜欢

Design and driver transplantation of matrix keyboard circuit of Ti am335x industrial control module

Ggplot2 learning summary

ggplot2学习总结

vite 本地运行首次进入页面加载慢问题
![[leetcode] 32. Longest valid bracket](/img/5e/45bb0b1ca3d9e429c6c5cf5c4c93ae.png)
[leetcode] 32. Longest valid bracket

由一个数据增量处理问题看到技术人员的意识差距

Error reporting caused by local warehouse

I.MX6UL核心模块使用连载-TF卡读写测试 (五)

1. Mx6ul core module serial Ethernet test (VII)
![[2020] [paper notes] growth of bi2te3/cofeb double-layer heterojunction by magnetron sputtering——](/img/5d/7d26e2d0d832c95e1cc011995ce774.png)
[2020] [paper notes] growth of bi2te3/cofeb double-layer heterojunction by magnetron sputtering——
随机推荐
Worthington nuclease and Micrococcus related research and determination scheme
【红队】ATT&CK - 利用BITS服务实现持久化
商业智能BI全解析,探寻BI本质与发展趋势
[cloud native] 4.1 Devops foundation and Practice
2022-07-17
1205 Lock wait timeout exceeded; try restarting transaction处理
I.MX6UL核心模块使用连载-CAN、蜂鸣器测试 (十一)
Turn: do the right thing efficiently
HTC手机官解、S-ON/S-OFF与超级CID的关系
1. Mx6ul core module serial Ethernet test (VII)
prometheus+process-exporter+grafana 监控进程的资源使用
Activiti workflow gateway
2022.7.25-----leetcode.919
mysql 事务隔离级别
I.MX6UL核心模块使用连载-WIFI测试 (八)
国标GB28181协议视频平台EasyGBS消息弹框模式优化
ggplot2学习总结
1. Mx6ul core module uses serial can and buzzer test (XI)
【2019】【论文笔记】基于超材料可调谐THz宽频吸收——
[C language brush leetcode] 1604. Warn people who use the same employee card more than or equal to three times within an hour (m)