踩坑!springboot对接vue axios报跨域问题
Access to XMLHttpRequest at 'localhost:8081/book/getAll' from origin 'http://localhost:8080' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data,
Access to XMLHttpRequest at 'localhost:8081/book/getAll' from origin 'http://localhost:8080' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
vue通过axios发送ajax请求到后端 但是一直报跨域问题,已经在后端springboot中配置跨域相关配置(网上有很多),但是依然报上述错误,最后排查,是前端发送请求的时候没带http://协议头,加上以后就好了
图一 (原错误代码)
图二(修改后代码)
控制台不再报错,并成功返回数据
更多推荐
所有评论(0)