Skip to content

Commit

Permalink
支持sameSite None
Browse files Browse the repository at this point in the history
  • Loading branch information
baozhoutao committed Dec 12, 2024
1 parent d0c122f commit af8ce39
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/utils/src/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function getSubdomain(host) {
}

export function setCookie(req, res, name, value, options = {domain: null, maxAge: 0, httpOnly: true, overwrite: true}) {
const cookies = new Cookies(req, res);
const cookies = sameSite === 'None' ? new Cookies(req, res, {secure: true}) : new Cookies(req, res);
const host = req.headers.host;
if(host && useSubdomainCookies && psl.isValid(host)){
const domain = getSubdomain(host);
Expand All @@ -32,7 +32,7 @@ export function setCookie(req, res, name, value, options = {domain: null, maxAge
}

export function clearCookie(req, res, name, options = {domain: null, maxAge: 0, httpOnly: true, overwrite: true}) {
const cookies = new Cookies(req, res);
const cookies = sameSite === 'None' ? new Cookies(req, res, {secure: true}) : new Cookies(req, res);
const host = req.headers.host;
if(host && useSubdomainCookies && psl.isValid(host)){
const domain = getSubdomain(host);
Expand Down

0 comments on commit af8ce39

Please sign in to comment.