i18next/i18next-http-middleware

Add the ability to configure the SameSite cookie option

martpie opened this issue ยท 4 comments

๐Ÿš€ Feature Proposal

On the latest Firefox releases, the following warning is issues (using via next-i18next).

Screen Shot 2020-05-22 at 17 03 31

From what I see, this option is not configurable (

const cookieOptions = {
expires: expirationDate,
domain: options.cookieDomain,
httpOnly: false,
overwrite: true
}
)

Is this something that could be added? https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite

Motivation

Prevent FF from breaking our website in a future release.

Example

{
  cookieSameSite: 'strict'
}

in the config.

I think this should not be too hard to implement, maybe I can submit a PR for that :)

adrai commented

PR are always welcome ;-)

adrai commented

adding: if (options.cookieSameSite) cookieOptions.sameSite = options.cookieSameSite here should do the trick: https://github.com/i18next/i18next-http-middleware/blob/master/lib/languageLookups/cookie.js#L85

and maybe an addition in the readme