springboot-vue模块中实现跨域问题时,出现200跨域正常,但跨域的端口还是前端端口,这是咋回事呢
#vue.config.js
module.exports = {
devServer: {
host:'localhost',
port:'8080',
proxy: { //设置代理,必须填
'/api': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
target: 'http://localhost:8888', //代理的目标地址
changeOrigin: true, //是否设置同源,输入是的
pathRewrite: { //路径重写
'/api': '' //选择忽略拦截器里面的单词
}
}
}
}
}
```bash
#这是vue中的方法
```javascript
save(){
request.post("/user",this.form).then(res => {
console.log(this.form)
})
},
你把pathRewrite像下面一样写一下试试,浏览器只要没有报跨域错误就不是跨域把,你是不是要检查一下你springboot的写法
pathRewrite:{
"^/api"
}