【发布时间】:2021-01-04 12:22:34
【问题描述】:
我有一个单页项目, 我想提交表单,但在我的 axios 请求尝试运行时收到 431 (Request Header Fields Too Large) 错误。 不知道还有什么可以尝试的,所以如果有人有任何建议,那就太好了!
我尝试过的事情:
set maxContentLength and maxBodyLength to Infinity,
added max-http-header-size
配置在哪里:
axios({
method: 'post',
url: 'http://example.com',
params: {a:b},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then(function (response) {
console.log(response)
}).catch(function (error) {
console.log(error)
})
params 内容长度较小的情况下,它可以工作。
但是,当参数内容长度太大(如 14kb)时, 它收到 431 错误(请求标头字段太大)
完整的 URL 如下所示:
http://localhost:9527/console/article/update?id=24321&title=%E5%8F%82%E4%B8%8E%E6%A0%87%E9%A2%9819000000061&image[]=&browseNumber=0&likeNum=1&shareNum=0&type=2&aspectType=0&status=1&userId=21334&admin=LZ000001&descStr=%E5%8F%82%E4%B8%8E%E5%86%85%E5%AE%B919000000061&roof=0&commodityIds[]=41&examine=1&htmlUrl=http:%2F%2Flocalhost:8080%2Fstatic%2Fhtml%2Fatlas%2B24321.html&isDel=0&sortNum=0&sortNo=0&createTime=2020-11-04+12:04:10&activityId=3&userNickName=iVQH4763&article=%3Cp%3E%E5%8F%82%E4%B8%8E%E5%86%85%E5%AE%B919000000061%3C%2Fp%3E&isLike=0&labelIds[]=8
我想这个错误是由于url的参数内容太大引起的。 而且我想不出正确配置的方法。 任何帮助将不胜感激。谢谢!
【问题讨论】:
-
什么是参数:{a:b}, ?我看过文档并且只在获取请求中看到“参数”
标签: javascript http axios