无法将字符串数组传递到typescript上的无服务器aws框架上的identitySource



当我尝试使用无服务器(typescript(将字符串数组分配给HTTP lambda authorizer的identitySource时,出现以下错误

Type '{ type: string; name: string; identitySource: string[]; resultTtlInSeconds: number; authorizerPayloadFormatVersion: string; }' is not assignable to type '{ arn?: AwsArn; authorizerId?: AwsCfInstruction; claims?: string[]; identitySource?: string; identityValidationExpression?: string; managedExternally?: boolean; name?: string; resultTtlInSeconds?: number; scopes?: string[]; type?: string; }'.
Types of property 'identitySource' are incompatible.
Type 'string[]' is not assignable to type 'string'

我们为什么可以使用多个identitySources

注意:是的,我使用authorizerPayloadFormatVersion作为"2.0">

authorizer: {
type: 'REQUEST',
name: 'authorizer',
identitySource: [
'method.request.header.Authorization',
'method.request.header.other-key',
],
},

它需要是一个包含所有用逗号分隔的值的字符串。所以在你的情况下,试试

authorizer: {
type: 'REQUEST',
name: 'authorizer',
identitySource: 'method.request.header.Authorization,method.request.header.other-key',
},

最新更新