问题描述
当我想使用VueJs作为前端(http://localhost:8080/#/login
)和Laravel 5.6作为后端创建身份验证系统时遇到问题.当我尝试使用api登录URL http://127.0.0.1:8000/api/v1/login
提交登录表单时,收到错误消息:
I have a problem when I want to create an authentication system using VueJs as the frontend (http://localhost:8080/#/login
) and Laravel 5.6 as the backend. When I try to submit login form using the api login url http://127.0.0.1:8000/api/v1/login
, I get the error message:
我不知道如何解决这个问题.
I don't know how to solve this problem.
这里有人可以帮助我解决我的问题吗?
Could anyone here help me to solve my problem?
注意:我必须先安装 laravel-cors
推荐答案
这是一个老问题,不过我还是会回答.
This is an old question, but I'll reply nonetheless.
对我来说,此错误是由自签名证书引起的.如果打开开发人员工具,请选择网络"选项卡,单击未通过CORS的呼叫,您可以看到安全性"选项卡.单击它以将其打开.如果证书给您带来问题,则应该显示文本发生错误:SEC_ERROR_INADEQUATE_KEY_USAGE".
For me this error was caused by a self-signed certificate. If you open developer tools, select the network tab, click the call that failed CORS you can see the security tab. Click it to open it. If a cert is giving you problems the text "An error occurred: SEC_ERROR_INADEQUATE_KEY_USAGE" should be visible.
要解决此问题,只需转到为您提供CORS错误的URL,然后手动接受该证书即可.
To resolve this just go to the URL that gave you the CORS error, and accept the cert manually.
这篇关于CORS要求未成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!