Firebase nodejs function set cookie TypeError: option sameSite is invalid

Viewed 1028

EDIT: This seems like a bug so I added an issue https://github.com/firebase/firebase-functions/issues/653

When handling request on deployed cloud function and setting cookie with sameSite 'none' option the 'TypeError: option sameSite is invalid' error is thrown.

const options = {
                    secure: true,
                    sameSite: 'none'
                };
res.cookie('session', cookieValue, options);

I could set a boolean value but that is not enough.

1 Answers

This is because of express version 4.16.x which uses cookie 0.3.0, which does not support sameSite:'none' option in cookies.

This support was added to the cookie npm version 0.4.x & above. To fix your issue, you can simply update expres, which is uses cookie version 0.4.x & above.

JFYR: Express Changelog: https://expressjs.com/en/changelog/4x.html

Related