Our netlify lambda works flawlessly on netlify dev mode, but when deployed with CI, it works only partially: it does return the proper responses for our requests, but it comes with 502 status, and its’ Set-Cookie header is empty.
The netlify function logs shows something like this:
3:10:10 PM: proxy invoked
3:10:10 PM: error decoding lambda response: json: cannot unmarshal array into Go value of type string
This is probably because we’re sending header that has a value which is an array.
For example: { headers: { 'Set-Cookie': ['a', 'b'] } }
Before this, we were sending them as { 'set-cookie': a, 'Set-cookie': b, 'sEt-cookie': c } (because that’s how serverless-http handles it - implementation for multiple working set-cookie headers by panva · Pull Request #16 · dougmoscrop/serverless-http · GitHub ), but when deployed to Netlify, responses were coming back with only one (the last one) set-cookie header ("c"). It appeared like Netlify was case insensitive when looking at the header keys and was skipping the first two "a" and "b" header values.
How can we send multiple Set-Cookie headers with netlify function?
We need this for our proxy server running with netlify.
FYI, I just received such message from support of Netlify:
Hi Jack,
Sorry to say there isn’t a workaround for this at the moment. We aren’t using AWS API gateway, we’re using our own. Right now there isn’t a way to return multiple set-cookie headers from a serverless function.
I got an issue filed on this for our team to work on. I don’t think this was implemented in this manner intentionally, I believe it’s more of a side-effect than anything else. As soon as I have more info I’ll update this thread, but I don’t know when that’ll be.