为什么Laravel中间件CORS无法与Vue.js一起使用 [英] Why did Not working Laravel middleware CORS with Vue.js

查看:215
本文介绍了为什么Laravel中间件CORS无法与Vue.js一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Laravel 5.7作为后端,并使用Vue.js作为前端.因此,我需要将Vue的http请求发送到Laravel后端.因此,我使用Laravel CORS软件包来使用github链接,如下所示: https://github.com/barryvdh/laravel -cors ,但不是成功,并且(不会将数据传递到表fue vue).并且我的控制台错误是跨域请求被阻止:同一起源策略不允许读取 http://上的远程资源本地主机: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 https://github.com/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 http://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一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆