Honour cookie domain on empty values

This commit is contained in:
Rory Powell 2021-09-29 13:51:33 +01:00
parent 435ba81852
commit 828da8b4d7
1 changed files with 14 additions and 16 deletions

View File

@ -67,24 +67,22 @@ exports.getCookie = (ctx, name) => {
* @param {string|object} value The value of cookie which will be set.
*/
exports.setCookie = (ctx, value, name = "builder") => {
if (!value) {
ctx.cookies.set(name)
} else {
if (value) {
value = jwt.sign(value, options.secretOrKey)
const config = {
maxAge: Number.MAX_SAFE_INTEGER,
path: "/",
httpOnly: false,
overwrite: true,
}
if (environment.COOKIE_DOMAIN) {
config.domain = environment.COOKIE_DOMAIN
}
ctx.cookies.set(name, value, config)
}
const config = {
maxAge: Number.MAX_SAFE_INTEGER,
path: "/",
httpOnly: false,
overwrite: true,
}
if (environment.COOKIE_DOMAIN) {
config.domain = environment.COOKIE_DOMAIN
}
ctx.cookies.set(name, value, config)
}
/**