使用Laravel 5.7作为后端,并使用Vue.js作为前端.因此,我需要将Vue的http请求发送到Laravel后端.因此,我使用Laravel CORS软件包来使用github链接,如下所示: github/barryvdh/laravel -cors ,但不是成功,并且(不会将数据传递到表fue vue).并且我的控制台错误是跨域请求被阻止:同一起源策略不允许读取 上的远程资源本地主机:8000/api/addItem . (原因:CORS请求未成功).
working with Laravel 5.7 as backend and Vue.js as frontend. so, I need send http request fron Vue to Laravel backend. so, I used Laravel CORS package to using github link as following github/barryvdh/laravel-cors but it is not sucess and (not pass data to table fron vue). and my console error is `Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at localhost:8000/api/addItem. (Reason: CORS request did not succeed).
如何解决此错误?`
推荐答案仅适用于localhost&在生产中,如果使用https,则不会再出现此问题.但是,对于本地测试,您可以在禁用的安全模式下打开chrome浏览器.有关操作方法的详细信息
It is only for localhost & in production if you use https then this issue will not raise any more. However for local test you can open chrome browser in disabled security mode. Details about how to do
Access-Control-Allow-Origin(Laravel& Vue)
更多推荐
为什么Laravel中间件CORS无法与Vue.js一起使用
发布评论