【问题标题】:Server does not receive HTTP headers that are sent by the browser?服务器没有收到浏览器发送的 HTTP 标头?
【发布时间】:2020-07-30 15:44:24
【问题描述】:

现在这非常奇怪。不知何故,我的 api 后端没有接收到 web 应用程序明确发送的 http 标头(特别是授权标头),正如在开发工具中看到的那样。但是,当我尝试从 GraphiQL 或 Postman 发送带有授权标头的请求时,服务器会收到它们。这怎么可能?

我的后端收到的 http 标头的日志:

map[Accept:[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9] Accept-Encoding:[gzip, deflate, br] Accept-Language:[de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7] Cache-Control:[no-cache] Connection:[keep-alive] Pragma:[no-cache] Sec-Fetch-Dest:[document] Sec-Fetch-Mode:[navigate] Sec-Fetch-Site:[none] Sec-Fetch-User:[?1] Upgrade-Insecure-Requests:[1] User-Agent:[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36]]

【问题讨论】:

    标签: http web http-headers google-chrome-devtools


    【解决方案1】:

    我发现了问题所在...它首先发送了 OPTIONS 请求,该请求是在没有此标头的情况下发送的。由于缺少 auth 标头,我的 api 拒绝了该请求,因此最终的 POST 请求从未发生。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-27
      • 1970-01-01
      • 2012-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多