Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs CORS不';当请求包含电子邮件字段laravel和react时不工作_Reactjs_Laravel_Cors_Digital Ocean - Fatal编程技术网

Reactjs CORS不';当请求包含电子邮件字段laravel和react时不工作

Reactjs CORS不';当请求包含电子邮件字段laravel和react时不工作,reactjs,laravel,cors,digital-ocean,Reactjs,Laravel,Cors,Digital Ocean,当我在没有电子邮件字段的情况下发出post请求时,它会发出请求并返回验证消息 但是,当我尝试发送电子邮件字段时,它允许此消息访问位于的XMLHttpRequest'https://example.api/api/auth/register“起源”http://example.com'已被CORS策略阻止:请求的资源上不存在'Access Control Allow Origin'标头。 我使用laravel 7.0作为后端,react作为前端,使用digital ocean作为后端部署。在获

当我在没有电子邮件字段的情况下发出post请求时,它会发出请求并返回验证消息

但是,当我尝试发送电子邮件字段时,它允许此消息
访问位于的XMLHttpRequest'https://example.api/api/auth/register“起源”http://example.com'已被CORS策略阻止:请求的资源上不存在'Access Control Allow Origin'标头。


我使用laravel 7.0作为后端,react作为前端,使用digital ocean作为后端部署。

在获取api时是否在标题中添加了“内容类型”:“应用程序/json”?

是的,我使用laravel 7附带的
水果蛋糕/laravel cors
,它支持所有内容,我使用axios进行请求,它在我从来没有得到过。我之所以这样做,是因为我有几个没有输入的头,API需要它。我曾经在本地使用过它,我的意思是,本地的API,本地的前端,它也发生过,尽管我已经输入了所有需要的东西。然后,当时的解决方案是使用CORS Firefox插件来杀死CORS。