optimizely / aws-lambda-at-edge-starter-kit

AWS Lambda at Edge Starter Kit for Optimizely Feature Experimentation and Optimizely Full Stack (legacy)
Apache License 2.0
1 stars 1 forks source link

Script failing on TypeError: Cannot read properties of undefined (reading 'OPTIMIZELY_USER_ID') #6

Open wcwcaseman opened 3 months ago

wcwcaseman commented 3 months ago

I pulled the aws-lambda-at-edge-starter-kit, then replaced OPTIMIZELY_SDK_KEY with my key and flag name with a flag I have. Then execute npm run build, upload the zip file to aws lambda at edge that I created with the nod 18 template. I then receive the following error when testing the code on aws, TypeError: Cannot read properties of undefined (reading 'OPTIMIZELY_USER_ID').

wcwcaseman commented 3 months ago

I removed the following line let userId = cookies[COOKIE_NAME_OPTIMIZELY_USER_ID] || ''; Then set it to let userId = ''; , this resolved my issue.

wcwcaseman commented 3 months ago

The above code fix allowed the lambda test to pass, however the actual response was 502. So I had to remove the headers from the response then I was finally able to get a response from lambda at edge. The following is the response I am using const response = { status: '200', statusDescription: 'OK', headers: {}, body: JSON.stringify(datafile), };

I also removed terser so I could read the code output. I hope this repo gets updated or this at least helps anyone else trying to integrate.