i18next/i18next-http-middleware

Cookie path option

gattaccio7 opened this issue ยท 1 comments

๐Ÿš€ Feature Proposal

Possibility to set up the language cookie path.

Motivation

It can be usefull if you need to manage 2 languages same time for frontend and backend.

Example

 const languageDetectorAdmin = new i18nextMiddleware.LanguageDetector(null, {
        order: ['querystring', 'cookie'],
        caches: ['cookie'],
        lookupCookie: 'i18nextAdmin',
        cookiePath: '/admin',
        lookupSession: 'i18nextAdmin',
    });

To achieve this result it is enough to add this in languageLookups/cookie.js, row 103:

var cookieOptions = {
        expires: expirationDate,
        domain: options.cookieDomain,
        path: options.cookiePath, // added
        httpOnly: false,
        overwrite: true,
        sameSite: options.cookieSameSite
      };
adrai commented

Thx, included in v2.1.0