vue前后台跨越请求简单总结

xiaoxiao2021-02-28  92

##vue-cli请求数据注意事项

vue-cli使用的Proxying

代理配置

/*config/index.js */ proxyTable: { //像这里我接口是http://www.xxxx.x.xxx:8080/portal/role/roles '/portal': { // /portal只要含有这个的就是我们要委托的url target: 'http://www.xxxx.x.xxx:8080', //target:被请求的地址 changeOrigin:true, //changeOrigin 是否代理

api.js配置

axios.defaults.withCredentials=true;/*设置session共享配合后台使用 */

后台配置

CorsConfiguration corsConfiguration = new CorsConfiguration(); corsConfiguration.addAllowedOrigin("*");//这个指点可以进来的地址 corsConfiguration.addAllowedHeader("*"); corsConfiguration.addAllowedMethod("*"); corsConfiguration.setAllowCredentials(true);//共享session配合前端使用

仅供参考, 实测有用

转载请注明原文地址: https://www.6miu.com/read-81533.html

最新回复(0)