简体   繁体   English

CORS没有'Access-Control-Allow-Origin'标头存在,但OPTIONS和POST请求却得到200,但

[英]CORS Getting No 'Access-Control-Allow-Origin' header is present but OPTIONS and POST request get 200 but

I cannot get a CORS request to work and this is day 4 battling with it. 我无法收到CORS的要求来工作,今天是第4天。 I am getting a 200 on my OPTIONS request and also a 200 on my POST request and all of the headers look like it should work, but I am still getting the error No 'Access-Control-Allow-Origin' header is present . 我在OPTIONS请求上收到200,在POST请求上收到200,所有标头看起来都应该正常工作,但是仍然出现错误No 'Access-Control-Allow-Origin' header is present

I am using Laravel (PHP) and the Fetch API in a React app. 我在React应用程序中使用Laravel(PHP)和Fetch API。

Here is a screenshot of my OPTIONS request and the following POST request: 这是我的OPTIONS请求和以下POST请求的屏幕截图:

OPTIONS request 选项要求

选项要求

POST request POST请求 在此处输入图片说明

What it ended up being was I had dd(variable) which is a dump and die, in my controller. 最终结果是我的控制器中有dd(variable) ,这是一个转储而死。 For some reason, this was causing the CORS error, which can be explained better here: look for this comment: davidnknight commented on Sep 26, 2014 由于某种原因,这导致了CORS错误,可以在此处进行更好的解释: 查找此评论:davidnknight于2014年9月26日发表评论

To paraphrase: If your backend is throwing errors or not completing successfully, you will get CORS errors because the correct headers are not being sent. 解释一下:如果后端抛出错误或未成功完成,则将收到CORS错误,因为未发送正确的标头。

So, make sure your backend is working properly. 因此,请确保您的后端工作正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Javascript CORS 请求,不存在带有 200 状态代码的“Access-Control-Allow-Origin”标头 - Javascript CORS request, No 'Access-Control-Allow-Origin' header is present with 200 status code 使用正确的标头和OPTIONS请求,仍会获得“所请求的资源上不存在Access-Control-Allow-Origin标头” - With correct headers and OPTIONS request, still getting “No Access-Control-Allow-Origin header is present on the requested resource” CORS标头“ Access-Control-Allow-Origin”丢失,但它出现在标头中 - CORS header 'Access-Control-Allow-Origin' missing but it present in the header CORS所请求的资源上没有“ Access-Control-Allow-Origin”标头 - CORS No 'Access-Control-Allow-Origin' header is present on the requested resource Web API 2 CORS不存在“ Access-Control-Allow-Origin”标头 - web api 2 CORS No 'Access-Control-Allow-Origin' header is present CORS“没有'Access-Control-Allow-Origin'标题存在”但是有 - CORS “No 'Access-Control-Allow-Origin' header is present” yet there is CORS-不存在“ Access-Control-Allow-Origin”标头 - CORS - No 'Access-Control-Allow-Origin' header is present CORS问题:获取错误“No'Access-Control-Allow-Origin'标题存在”实际存在时 - CORS issue: Getting error “No 'Access-Control-Allow-Origin' header is present” when it actually is 启用了 Elasticsearch https cors,但仍然在请求的资源上不存在“Access-Control-Allow-Origin”标头 - Elasticsearch https cors enabled but still getting No 'Access-Control-Allow-Origin' header is present on the requested resource AJAX请求中不存在“ access-control-allow-origin”标头 - No 'access-control-allow-origin' header is present in AJAX request
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM