为什么Laravel中间件CORS无法与Vue.js一起使用

编程入门 行业动态 更新时间:2024-10-27 16:33:32
本文介绍了为什么Laravel中间件CORS无法与Vue.js一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用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一起使用

本文发布于:2023-11-24 19:26:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626507.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中间件   Laravel   CORS   js   Vue

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!