PanJiaChen / vue-element-admin

:tada: A magical vue admin https://panjiachen.github.io/vue-element-admin
MIT License
87.82k stars 30.44k forks source link

Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. #941

Closed Acumes closed 6 years ago

Acumes commented 6 years ago

xhr.js:178 Failed to load localhost:8087/open/api/user/login: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

这个配置了--allow-file-access-from-files 还是没法解决呀, 后端配置过跨域处理的 , 其他Vue项目都能够访问

gangyahaidao commented 6 years ago

这个工程在跨域方面是没有问题的,我的实现是vue工程中只修改了需要访问的后台接口地址,开发调试阶段在dev.env.js中修改BAE_API的值,其他的不需要改,跨域的支持在服务端做的,服务端采用的springMVC架构

Acumes commented 6 years ago

我的也是springmvn 但是其他Vue访问我的没有问题 这个项目就有这个浏览器的问题 , 这个怎么解决?

gangyahaidao commented 6 years ago

我说一下我的前后端设置吧, 前端: 在config/index.js的dev模式中设置“assetsPublicPath: '/',” build模式中设置“assetsPublicPath: '/vue-element-admin/',”,然后dev.env.js中设置:“BASE_API: '"http://localhost:8098/SellRobotSys"'”指向我本地的springMVC后台,如果是打包发布的话就需要再修改成对应的值就好了

后端在web.xml中添加一个CORS的过滤器就好了,可以使用网上现成的jar包,也可以自己写,配置如下 image 这样我使用是没有问题的

Acumes commented 6 years ago

我的是springboot的。 这个我是配置了的。。公司电脑会出现上述问题,回到家里就可以了, 不知道为甚恶魔。。

Panpan0403 commented 6 years ago

我也是这个问题,求问是怎么解决的啊