相关疑难解决方法(0)

如何修复 React-Redux 应用程序中 431 请求头字段太大的问题

我正在 youtube 上完成使用 Redux 的 MERN 注册/登录身份验证教程。在 Postman 中尝试将测试用户 POST 到服务器时,我收到 431 标头请求太大错误响应。

我在某些地方读到清除浏览器中的缓存/历史记录是有效的,所以我尝试过无济于事。我还在标题请求中添加了一个 "Clear-Site-Data": "*" 条目(除了 "Content-Type": "application/json"),它也没有工作。

用于注册的客户端代码

  onSubmit = e => {
    e.preventDefault();
    const { name, email, password } = this.state;

    const newUser = {
      name,
      email,
      password
    };

    this.props.register(newUser);
  };

//redux actions
export const register = ({ name, email, password }) => dispatch => {

  const config = {
    headers: {
      "Content-Type": "application/json",
      "Clear-Site-Data": "*"
    }
  };

  // Request body
  const body = JSON.stringify({ name, email, …
Run Code Online (Sandbox Code Playgroud)

request-headers http-headers reactjs redux

15
推荐指数
4
解决办法
3万
查看次数

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

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

我尝试过的事情:清除我的谷歌浏览器缓存和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)

javascript node.js express reactjs redux

6
推荐指数
1
解决办法
2万
查看次数