431 -(请求标头字段太大)

92y*_*2yo 6 javascript node.js express reactjs redux

第一次发帖,请阅读时牢记

我尝试过的事情:清除我的谷歌浏览器缓存和cookie,尝试隐身模式,将我的节点更新到最新版本仍然遇到相同的错误。

我获取 chrome 时出错:无法加载资源:服务器响应状态为 431(请求标头字段太大)

auth.js:22怀疑它的相关性,但是开发工具中的源代码在获取部分给我错误

export const authInit = data => {
      const { user, type } = data;
      let url;
      if (type === "Login") {
        url = "/api/auth/login";
      } else if (type === "Register") {
        url = "/api/auth/register";
      }
      return dispatch => {
        dispatch({ type: actionTypes.LOADING });
        return fetch(url, {
          method: "POST",
          body: JSON.stringify(user),
          headers: {
            "Content-Type": "application/json"
          }
        })
          .then(res => res.json())
          .then(response => {
            if (!response.success) {
              return dispatch(authError(response.messages));
            }
Run Code Online (Sandbox Code Playgroud)

Pim*_*Web 4

也许你应该尝试这个。

它谈论的是有关 Node js 标头大小的错误:

文章

您应该使用--max-http-header-size=16384for 例如运行节点。

如果您使用 运行服务器npm start,那么只需修改package.json


也许 Express 的主体解析器存在另一个问题?

var bodyParser = require('body-parser')
app.use(bodyParser(){limit:5000kb})
Run Code Online (Sandbox Code Playgroud)

您可以在此处找到有关身体选项的文档