提供的路由键格式不适合 HTTP 协议

The provided route key is not formatted properly for HTTP protocol

An error occurred: HttpApiRoutePostv1Banks - The provided route key is not formatted properly for HTTP protocol. Format should be "[HTTP METHOD] /[RESOURCE PATH]" or "$default" (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: 38370b30-9c11-4a66-9f2d-710fd2c25329; Proxy: null).

provider:
  ...
  httpApi:
    payload: '2.0' # Define Http format needed for API GW
  ...
functions:
  banksCreate:
    handler: src/banks.create
    events:
      - httpApi: 'POST v1/banks'

我已经根据 official documentation

设置了 serverless.yml 文件

当我 运行 无服务器离线时一切正常,但是当我尝试部署时出现上述错误。

我不知道我哪里弄错了?

请注意,restApi 事件

部署正常

注意:错误消息显示 [HTTP METHOD] /[RESOURCE PATH] 这意味着 / 应该在路径开始和路径之间用空格分隔 space.

provider:
  ...
  httpApi:
    payload: '2.0' # Define Http format needed for API GW
  ...
functions:
  banksCreate:
    handler: src/banks.create
    events:
      - httpApi: 'POST /v1/banks'