Angular 8 代理和 oauth2 400 错误请求
Angular 8 proxy and oauth2 400 bad request
将我的 angular-app 从 angular 7.2.11 升级到 angular 8.1.3 后。
Angular HttpClientModule 在使用代理时不发送我的 oauth2 安全请求。
- angular-app 在我部署它并且不使用代理时工作。
- HttpClientModule 在使用代理但不使用 oauth2-tokens 时工作
Proxy-config:
{
"/oauth/*": {
"target": "http://localhost:8090",
"secure": false,
"logLevel": "debug"
},
"/api/**": {
"target": "http://localhost:8090",
"secure": true,
"logLevel": "debug",
"changeOrigin": true
}
}
Oauth2-config(使用@auth0/angular-jwt 3.0.0)
HttpClientModule,
JwtModule.forRoot({
config: {
tokenGetter: tokenGetter
}
}),
- oauth2 调用被代理
- api-calls 被代理
- 带有 oauth2 承载 header 的 api-calls 导致 400 错误请求。
我找到了解决方案,我的 oauth2-token 似乎变得太大了,它在 angular 代理上达到了 http-header-limit。
我已经用下面的命令解决了:
`"scripts":{
"start": "node --max-http-header-size=100000 ./node_modules/@angular/cli/bin/ng serve --host=0.0.0.0 --proxyConfig=proxy.conf.json -o",
},`
将我的 angular-app 从 angular 7.2.11 升级到 angular 8.1.3 后。
Angular HttpClientModule 在使用代理时不发送我的 oauth2 安全请求。
- angular-app 在我部署它并且不使用代理时工作。
- HttpClientModule 在使用代理但不使用 oauth2-tokens 时工作
Proxy-config:
{
"/oauth/*": {
"target": "http://localhost:8090",
"secure": false,
"logLevel": "debug"
},
"/api/**": {
"target": "http://localhost:8090",
"secure": true,
"logLevel": "debug",
"changeOrigin": true
}
}
Oauth2-config(使用@auth0/angular-jwt 3.0.0)
HttpClientModule,
JwtModule.forRoot({
config: {
tokenGetter: tokenGetter
}
}),
- oauth2 调用被代理
- api-calls 被代理
- 带有 oauth2 承载 header 的 api-calls 导致 400 错误请求。
我找到了解决方案,我的 oauth2-token 似乎变得太大了,它在 angular 代理上达到了 http-header-limit。
我已经用下面的命令解决了:
`"scripts":{ "start": "node --max-http-header-size=100000 ./node_modules/@angular/cli/bin/ng serve --host=0.0.0.0 --proxyConfig=proxy.conf.json -o",
},`