spring boot + vue + axios配置跨域

1,spring boot配置项:需要注意的是spring boot中有许多类名相同的,避免引错包。


包路径

设置过滤配置项,并将过滤器注入spring boot 容器

2,前台配置(当前项目使用vue-cli搭建的项目)

        编辑 config/index.js文件,添加proxyTable   target指向后台服务ip+port      


主要配置项

需要提一下的是pathRewrite    即路径重写

配置之后访问后台时:/api/接口名  axios就会自动将当前的ip和端口换成target的内容

猜你喜欢

转载自www.cnblogs.com/lzwnodes/p/11653451.html