Skip to content

Commit 70e6399

Browse files
committed
fixup! Rewrite cookie path logic
1 parent 5a63f49 commit 70e6399

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/node/http.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -274,17 +274,13 @@ export const getCookieOptions = (req: express.Request): express.CookieOptions =>
274274
// When logging in or out the request must include the href (the full current
275275
// URL of that page) and the relative path to the root as given to it by the
276276
// backend. Using these two we can determine the true absolute root.
277-
let domain = req.headers.host || ""
278-
let pathname = "/"
279-
const href = req.query.href || req.body.href
280-
if (href) {
281-
const url = new URL(req.query.base || req.body.base || "/", href)
282-
domain = url.host
283-
pathname = url.pathname
284-
}
277+
const url = new URL(
278+
req.query.base || req.body.base || "/",
279+
req.query.href || req.body.href || "http://" + (req.headers.host || "localhost"),
280+
)
285281
return {
286-
domain: getCookieDomain(domain, req.args["proxy-domain"]),
287-
path: normalize(pathname) || "/",
282+
domain: getCookieDomain(url.host, req.args["proxy-domain"]),
283+
path: normalize(url.pathname) || "/",
288284
sameSite: "lax",
289285
}
290286
}

0 commit comments

Comments
 (0)