[AWS] Solve Error: Lambda Options Request UnAuthorized


If you configure CORS (Cross-Origin Resource Sharing) for an API, API Gateway automatically sends a response to preflight OPTIONS requests, even if there isn’t an OPTIONS route configured for your API.

At this time, you might want to disable your OPTIONS request authorizer, otherwise the preflight call might get unauthorized. You can disable it when define your authorizers in the SAM (Serverless Application Model) template by adding AddDefaultAuthorizerToCorsPreflight: False. For example:

Auth:
  DefaultAuthorizer: MyLambdaTokenAuthorizer
  Authorizers:
    MyLambdaTokenAuthorizer:
      FunctionArn: !GetAtt ValidateTokenFunction.Arn
  AddDefaultAuthorizerToCorsPreflight: False

Refereces:

Configuring CORS for an HTTP API

原创文章,作者:306829225,如若转载,请注明出处:https://blog.ytso.com/268328.html

(0)
上一篇 2022年6月19日
下一篇 2022年6月19日

相关推荐

发表回复

登录后才能评论