Skip to content
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

adapter-netlify: Support multiValueHeaders key in returned object from handler function #1741

Closed
f-elix opened this issue Jun 23, 2021 · 2 comments · Fixed by #1906
Closed

Comments

@f-elix
Copy link
Contributor

f-elix commented Jun 23, 2021

Is your feature request related to a problem? Please describe.
Netlify Functions allow a multiValueHeaders key in the returned object of the handler function. This key is specifically made for array values.

For example, as the Svelte-kit docs say, in order to set multiple cookies in a response, you can do the following in an endpoint:

return {
  headers: {
    'set-cookie': [cookie1, cookie2]
  }
};

However, this fails when deployed to Netlify. In order to set multiple cookies in a Netlify function, you have to do this:

return {
  multiValueHeaders: {
    'set-cookie': [cookie1, cookie2]
  }
}

This is documented here: https://docs.netlify.com/functions/build-with-javascript/#synchronous-function-format.

Describe the solution you'd like
A way to set multiple cookies with the Netlify adapter, ideally keeping the same API as described above. The adapter should check for array values in the rendered headers object and transfer them in a multiValueHeaders key in the returned response.

Describe alternatives you've considered
There isn't really any alternatives to this, as the only way to set multiple cookies in a response with Netlify functions is through this key.

How important is this feature to you?
Very! Setting multiple cookies is supposed to be a supported feature in Svelte-kit. Also, most auth systems are going to be able to do this.

@JeanJPNM
Copy link
Contributor

Is there anything else to discuss before I start to code the fix?

@f-elix
Copy link
Contributor Author

f-elix commented Jul 16, 2021

@JeanJPNM Oh my god thank you so much for this! I wanted to get to it but couldn't find the time. I can't understate how good that timing is.

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

Successfully merging a pull request may close this issue.

3 participants