错误无法为无服务器自定义域设置基域映射

Error Unable to setup base domain mappings for serverless custom domain

在 serverless.yml 中,在自定义下,我有以下代码(这里有虚拟值):

customDomain:
    domainName: myhost.mydomain.com
    basePath: ''
    stage: ${self:provider:stage}
    createRouteS3Record: true
    endpointType: 'edge'
    securityPolicy: tls_1_2
    certificateArn: 'arn:aws:acm:.................'
    hostZoneId: 'P4OCK4S1PSTZK' 

当我执行无服务器部署时,一切都很顺利。 Api 为我的函数正确生成。 (在函数下我有 events: http

但是在 API 部署生成的 lambda 之后,我收到以下错误:

Error: Error: Unable to setup base domain mappings for myhost.mydomain.com

除了https://forum.serverless.com/t/error-unable-to-setup-base-domain-mappings/11395,我没有得到太多信息 如果这是解决方案,不知道如何在无服务器中包含 api 版本。

好吧,小事情可能会导致大问题,而且有时很难弄清楚。 我发现stage: ${self:provider:stage}不对,应该是stage: ${self:provider.stage}。提供者后面的冒号是罪魁祸首。

我在拥有域映射、删除它、然后再次尝试添加它之后遇到此错误:Serverless 似乎没有完全删除域映射。

我必须转到自定义域名 -> 我的域 -> API 映射 -> 配置 API 映射并在重新部署之前手动删除域映射。

有同样的问题。在我的 serverless.yml 文件中的事件内部函数中,我有 'httpApi'。将其更改为 'http' 解决了我的问题

functions:
 getWebHooks:
   handler: src/path
   events:
    - httpApi:
       path: /

functions:
 getWebHooks:
   handler: src/path
   events:
    - http:
       path: /

我收到该错误消息是因为我(不知何故)得到了相同的 api 副本。所以我去了

API Gateway -> Custom domain name -> {name_of_my_domain} -> API Mappings -> Configure API Mappings

然后我更改了 API 以使用正确的 API(保留我在我的应用程序中拥有的路线,并且我可以使用它们的 ID 区分两者)。使用无服务器重新部署成功