【发布时间】:2018-03-29 10:17:56
【问题描述】:
我对 CORS 有一个奇怪的问题。我正在从文件中发出请求,我的问题从今天开始,在它工作之前(它仍在 firefox 上工作)。但是在 chrome 上我遇到了一个问题,它说服务器端不允许使用“null”来源。但如果我检查网络,我可以看到:
Response
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: accept, content-type
Access-Control-Allow-Methods: PUT, DELETE, POST, GET, OPTION
Access-Control-Allow-Origin: null
Connection: close
Content-Length: 21
Content-Type: application/json
Date: Thu, 29 Mar 2018 10:10:53 GMT
Request
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Authorization: Basic somePasswordHere
Connection: keep-alive
Host: localhost:8080
Origin: null
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
我现在在发布之前修改的“somePasswordHere”实际上是基本身份验证中的用户名和密码。
奇怪的是,我在 chrome 上的控制台中得到了这个:The 'Access-Control-Allow-Origin' header has a value 'null' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access.
如果我检查我的服务器,我可以看到我收到来自空源的请求并且我允许它,我可以看到有凭据和东西,并且实际的 cal 处理正确,但是在 chrome 端我得到了这个反正消息。
奇怪的是,它可以在 Firefox 上运行(通常情况相反)。
有什么想法吗?我是否必须为 chrome 或其他东西添加另一个标题?
PS:我可以看到 chrome 昨天更新了,所以它可能已经损坏了一些东西。
PS2:在网络选项卡的“响应预览”中的另一个奇怪的事情是,我实际上可以看到内容是正确的并且它在那里......但是消息'提供的来源不同于......'仍然存在 dahell?
【问题讨论】: