Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wcwcaseman opened this issue Jun 7, 2024 · 2 comments

Comments

@wcwcaseman
Copy link

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
Copy link
Author

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

@wcwcaseman
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant