且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

预检的响应无效(重定向)错误

更新时间:2023-10-21 16:20:58

由于请求中的标头无效/不正确,您可能会遇到问题。 PlaceController 似乎允许的唯一类型的标头是 Content-Type ,但是你发送的不仅仅是那个。

You might be having problems due to invalid/incorrect Headers in your request. The only type of header that PlaceControllerseems to allow is Content-Type, but you're sending more than that.

此外, Access-Control-Allow-Origin Access-Control-Allow-方法标题应该添加到您的请求的服务器响应中,而不是添加到请求本身。

Also, Access-Control-Allow-Origin and Access-Control-Allow-Methods headers should be added to the server response for your request, not to the request itself.

来自 MDN ,跨站点请求(似乎是您的情况)必须满足以下条件:

From MDN, cross-site requests (which seems to be your case) have to meet the following conditions:



  • 唯一允许的方法是:


    • GET

    • HEAD

    • POST


  • 接受

  • 接受语言

  • Content-L anguage

  • 内容类型

  • Accept
  • Accept-Language
  • Content-Language
  • Content-Type

  • application / x-www-form-urlencoded

  • multipart / form-data

  • text / plain

注意:我从未使用Laravel或Lumen,但在我的情况下如果我没有正确设置标题我最终得到相同的预检的响应无效(重定向) 错误。

Note: I never worked with Laravel or Lumen, but in my case if I don't set the headers correctly I end up with the same response for preflight is invalid (redirect) error.