使用 Angular-CLI 运行时设置节点选项

And*_*i S 9 asp.net-core angular-cli angular

应用程序返回 400,因为它大约有 3 个 cookie 4k bytes。我试图max-http-header-size在运行应用程序时设置属性angular cli。( ng serve)

该应用程序在生产中运行时按预期工作。

技术:

angular CLI: 8.1.3
asp.net core 2.1.3
Run Code Online (Sandbox Code Playgroud)

尝试运行node --max-http-header-size=14000但它不起作用。

And*_*i S 6

解决方案是在调用 ngserve 函数之前设置最大标头大小的值:node --max-http-header-size=100000 ./node_modules/@angular/cli/bin/ng serve

如果您使用的是 ASP.NET Core,则可以在 package.json 中添加以下内容:

"scripts": {
    "ng": "ng",
    "start": "node --max-http-header-size=100000 ./node_modules/@angular/cli/bin/ng serve",
    "build": "ng build"
}
Run Code Online (Sandbox Code Playgroud)