awslabs / cognito-at-edge

Serverless authentication solution to protect your website or Amplify application
Apache License 2.0
189 stars 56 forks source link

TypeError - Cannot read properties of undefined (reading 'querystring') #84

Open prachimore1406 opened 9 months ago

prachimore1406 commented 9 months ago

I'm facing this error while testing the Lambda@edge function with a CF distribution:

===================================================================== From the Lambda logs -

Response { "errorType": "TypeError", "errorMessage": "Cannot read properties of undefined (reading 'querystring')", "trace": [ "TypeError: Cannot read properties of undefined (reading 'querystring')", " at Authenticator.handle (/var/task/node_modules/cognito-at-edge/dist/index.js:511:64)", " at Runtime.exports.handler (/var/task/index.js:11:52)", " at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)" ] }

503 ERROR The request could not be satisfied. The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.

Lambda function:

const { Authenticator } = require('cognito-at-edge');

const authenticator = new Authenticator({ // Replace these parameter values with those of your own environment region: 'us-east-1', // user pool region userPoolId: 'xxx', // user pool ID userPoolAppId: 'xxxx', // user pool app client ID userPoolDomain: 'xxxx', // user pool domain });

exports.handler = async (request) => authenticator.handle(request); Can someone assist in addressing this please.