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

时间:2021-06-03 21:23:29

标签: aws-lambda nestjs

我已将 NestJS 应用发布到 AWS Lambda

当我尝试打开根 URL 时

https://xxx/

正确显示“Hello World”

但是当我打开时:

https://xxx/sales/subscription

显示Missing Authentication Token消息

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

1 个答案:

答案 0 :(得分:0)

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

因此,显然 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