其他分享
首页 > 其他分享> > [AWS] Solve Error: Lambda Options Request UnAuthorized

[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

标签:False,UnAuthorized,AWS,Request,your,API,preflight,MyLambdaTokenAuthorizer,OPTION
来源: https://www.cnblogs.com/grandyang/p/16389831.html