为什么会出现400个错误?节点,Express,ReactJS [英] Why am I getting 400 errors? Node, Express, ReactJS

查看:61
本文介绍了为什么会出现400个错误?节点,Express,ReactJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我已经从我的reactJS服务URL接收到400个错误,但是我在其他微服务上没有收到它们.这是我尝试过的:

Recently, i've been receiving 400 errors from my reactJS service urls, but I don't receive them on my other microservices. Here is what I tried:

  1. 查看 express 来查找是否有400个错误来自此,但没有成功.

  1. Looking into express to find out if 400 errors are coming from there, no success.

浏览到反应代码,那里不会出现400个错误.

Digging into react code, no 400 errors should be coming from there.

正在浏览chrome控制台....但是它什么也没有.

Looking into the chrome console.... but it has nothing.

它甚至看上去都没有收到服务器上的任何日志,所以好像它从未命中,因此那里没有日志.

It doesn't even look like i'm receiving any logs on my server so it's like it never hit, so no logs there.

我的节点版本为 10.15.3 ,但我所有其他微服务均为 10.13.0 .

My node version is 10.15.3 but all my other microservices are 10.13.0.

为什么我从react/express NextJS微服务中收到400个错误?

推荐答案

2018年11月,进行了PR,这是对最大标头大小的重大更改.标头的大小只能为8kb.

In november 2018 a PR was made that was a breaking change to the max header size. Headers can only be 8kb in size.

受影响的节点版本是v6.15.0,v8.14.0,v10.14.0,v11.3.0(请参阅 https://www.nearform.com/blog/protecting-node-js-from-uncontrol-resource-consumption-headers-attacks/)

The node versions affects are v6.15.0, v8.14.0, v10.14.0, v11.3.0 (see https://www.nearform.com/blog/protecting-node-js-from-uncontrolled-resource-consumption-headers-attacks/)

您可以做两件事之一...

You can do one of two things...

  1. 还原为v10.13.0

  1. Reduce to v10.13.0

添加标志-max-http-header-size = 10000

背景

为避免DoS攻击,最大大小从80kb减小到8kb.如果您的站点上有很多Cookie,那么您将收到400错误而没有太多输出.在此处阅读有关PR和讨论的更多信息: https://github.com/nodejs/node/issues/24692 ,这里是PR( https://github.com/nodejs/node/commit/92231a56d9 )

To avoid DoS attacks the max size was reduced from 80kb to 8kb. If you have a lot of cookies on your site you will receive a 400 error without much output. Read more about the PR and discussions here: https://github.com/nodejs/node/issues/24692 and here is the PR (https://github.com/nodejs/node/commit/92231a56d9)

测试

要对此进行测试,可以将curl请求与超过8kb的巨大cookie一起使用,并且应该收到400错误.调整该最大值后,它应该可以工作.

To test this, you can use a curl request with a gigantic cookie that is over 8kb and you should receive a 400 error. After adjusting this max value, it should work.

这篇关于为什么会出现400个错误?节点,Express,ReactJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆