如何解决错误“缺少身份验证令牌”

How to solve error `Missing Authentication Token`

我已经将我的 NestJS 应用程序发布到 AWS Lambda

当我尝试打开根目录时URL

https://xxx/

它正确显示“Hello World”

但是当我打开时:

https://xxx/sales/subscription

它显示 Missing Authentication Token 消息

有没有人遇到过这种问题?

我已经解决了这个问题,我在这里分享解决方案,希望它能帮助遇到同样问题的人。

所以,显然 Missing Authentication Token 表示路由不存在。

该应用程序已使用无服务器框架部署到 AWS Lambda。

我通过简单地打开 serverless.yaml 文件解决了这个问题,然后在 functions 部分注册了路由。 之前:

functions:
 main: # The name of the lambda function
   # The module 'handler' is exported in the file 'src/lambda'
   handler: src/lambda.handler
   events:
     - http:
         method: any
         path: /

之后:

functions:
 main: # The name of the lambda function
   # The module 'handler' is exported in the file 'src/lambda'
   handler: src/lambda.handler
   events:
     - http:
         method: any
         path: /
     - http:
         method: any
         path: /sales/subscription