storyblok / storyblok-js

JavaScript SDK to connect Storyblok with your favourite framework that we don't have an official SDK for.
http://storyblok.com/
MIT License
39 stars 20 forks source link

'Header is not defined error' when using Storyblok API client from version 2.1.0 in AWS lambda #256

Closed kethzi-gilbert closed 10 months ago

kethzi-gilbert commented 1 year ago

I observe an error when I create a AWS Lambda function which fetches stories data from a storyblok space using Storyblok API Client. This lambda is triggered using an API on AWS API Gateway. I receive the error "ReferenceError: Headers is not defined" (shown in the screenshot below). This error is observed only when i use "@storyblok/js" version 2.1.0. When i downgrade the library version to 1.8.5, i don't see this error.

Expected Behavior

Should be able to fetch the stories from the API in the lambda function.

Current Behavior

I receive the below error image

The lambda Handler code is as below

image

image

SebbeJohansson commented 1 year ago

I am seeing the same issue in Vue/Nuxt3. image image

thomas-ef commented 1 year ago

Same error here

henrykuijpers commented 1 year ago

@kethzi-gilbert Did you try https://www.storyblok.com/faq/headers-not-defined-storyblok-sdk ?

fgiuliani commented 1 year ago

@kethzi-gilbert @SebbeJohansson @thomas-ef has any of you tried what @henrykuijpers shared? Did it work?

SebbeJohansson commented 1 year ago

I have not tested, but Im pretty sure I was running nodejs 18 so I shouldn't have to do the polymorph. But as I said, I haven't tested it in a long time. Might be that I was running it weirdly or something. Nuxt3 should be working fine now.