Skip to content

Commit

Permalink
fixed date issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
netptop committed Sep 19, 2020
1 parent 286ed34 commit 972c7a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions Proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,13 @@ let Proxy = ({ProxyMiddleware, blockedSites, urlModify, httpprefix, serverName,
const setCookieHeaders = proxyRes.headers['set-cookie'] || []
console.log(`1`)
let datestr = ''
let datestrOriginHost = ''
if (setCookieHeaders.length > 0) {
let date = new Date
date.setDate(date.getDate() + 1) // 一天之后过期
let curDate = new Date()
let date = new Date(curDate.getTime() + 7200 * 1000) // 2 hours later
datestr = date.toUTCString()
date = new Date(curDate.getTime() + 600 * 1000) // 10 mins later
datestrOriginHost = date.toUTCString()
}
console.log(`2, setCookieHeaders:${JSON.stringify(setCookieHeaders)}`)
const modifiedSetCookieHeaders = setCookieHeaders
Expand All @@ -453,7 +456,7 @@ let Proxy = ({ProxyMiddleware, blockedSites, urlModify, httpprefix, serverName,
cookie_originalHost.name = 'ORIGINALHOST'
cookie_originalHost.value = `${httpType}/${host}`
cookie_originalHost.domain = `${serverName}`
cookie_originalHost.expiration_date = datestr
cookie_originalHost.expiration_date = datestrOriginHost
cookie_originalHost.path = `/`
cookie_originalHost.secure = false
modifiedSetCookieHeaders.push(cookie_originalHost.toString())
Expand Down
Loading

0 comments on commit 972c7a6

Please sign in to comment.