reactMaxHeadersLength
在静态渲染期间,React 可以发出可以添加到响应中的标头。通过允许浏览器预加载字体、脚本和样式表等资源,可以使用它们来提高性能。默认值为 6000
,但你可以通过配置 next.config.js
中的 reactMaxHeadersLength
选项来覆盖此值:
¥During static rendering, React can emit headers that can be added to the response. These can be used to improve performance by allowing the browser to preload resources like fonts, scripts, and stylesheets. The default value is 6000
, but you can override this value by configuring the reactMaxHeadersLength
option in next.config.js
:
module.exports = {
reactMaxHeadersLength: 1000,
}
很高兴知道:此选项仅在 App Router 中可用。
¥Good to know: This option is only available in App Router.
根据浏览器和服务器之间的代理类型,标头可以被截断。例如,如果你使用的反向代理不支持长标头,则应设置较低的值以确保标头不会被截断。
¥Depending on the type of proxy between the browser and the server, the headers can be truncated. For example, if you are using a reverse proxy that doesn't support long headers, you should set a lower value to ensure that the headers are not truncated.