我注意到一个奇怪的警告信息,当使用谷歌chrome检查器(F12)查看下载的资源:

注意显示临时标题

我发现一些可能相关的东西,网络面板:添加临时请求头的警告,但我不能完全理解它。相关问题可以发现Chrome块请求以及XMLHttpRequest无法加载。未加载的资源显示警告:显示临时标头。

与第一个问题类似,我的资源被阻塞了,但后来自动加载了相同的资源。不像第二个问题,我不想解决任何问题;我想知道这条信息是什么意思以及我为什么收到它。


当前回答

My situation is cross-origin related. Situation: Browser sends OPTIONS request before sending the real request like GET or POST. Backend developer forgets to deal with the OPTIONS request, letting it go through the service code, making the processing time too long. Longer than the timeout setting I wrote in the axios initialization, which is 5000 milliseconds. Therefore, the real request couldn't be sent, and then I encountered the provisional headers are shown problem. Solution: When it comes to OPTIONS request, backend api just return result, it makes the request faster and the real request can be sent before timeout.

其他回答

在我的情况下,我在post请求中发送的主体参数,以及我根据主体参数编写的逻辑都是错误的,因此无法发送响应。所以我得到了这个错误。

 example: post request body (a: alsldfjfj) which I was sending

但我写的代码是验证“b”而不是“a”

我相信当实际的请求没有发送时就会发生这种情况。通常在加载缓存资源时发生。

如果您正在开发Asp。Net Mvc应用程序,你试图返回一个JsonResult在你的控制器,确保你添加了JsonRequestBehavior。AllowGet到Json方法。这为我解决了问题。

public JsonResult GetTaskSubCategories(int id)
{
    var subcategs = FindSubCategories(id);

    return Json(subcategs, JsonRequestBehavior.AllowGet);  //<-- Notice it has two parameters
}

当我发送无效的HTTP授权报头时,发生了这个问题。我忘记用base64编码了。

当使用一些包(如webpack-hot-middleware)并同时打开多个页面时,也会出现此问题。Webpack-hot-middleware将为每个页面创建一个连接,用于侦听代码的更改,然后刷新页面。每个浏览器都有每个服务器最大连接数限制,对于Chrome来说是6个,所以如果你已经在Chrome中打开了超过6个页面,新的请求将一直挂在那里,直到你关闭一些页面。