shopify-api-js icon indicating copy to clipboard operation
shopify-api-js copied to clipboard

Allow both `string` and `string[]` for cookies

Open mkevinosullivan opened this issue 3 years ago • 2 comments

From https://github.com/Shopify/shopify-api-node/issues/517#issuecomment-1266734204

I was confused with the Cookie header parsing in the src/runtime/http/cookies. In the constructor it expects the Cookie header to be passed as a semi-colon separated string. However, the generic headers in src/runtime/http/types that is used in the NormalizedRequest interface allow for both string and string[]. This is relevant because, e.g., the src/auth/oauth/oauth.ts createCallback uses both the normalized requests and also the cookie class. My intuition for the abstractConvertRequest function was to pass the cookies (i.e. state cookie + signature cookie) as a list of cookies, when in reality the cookie header needs to be a single string. (Passing the cookies as a list leads to the Cookie class to only respect the very first cookie in the list)

mkevinosullivan avatar Oct 06 '22 21:10 mkevinosullivan