Handle undefined body

In the latest Express it seems the body is undefined when no data is
passed (instead of being empty).
This commit is contained in:
Asher
2024-04-16 11:13:36 -08:00
parent 3d8d544f89
commit fb2afbd9d6
4 changed files with 38 additions and 36 deletions

View File

@@ -319,8 +319,8 @@ export const getCookieOptions = (req: express.Request): express.CookieOptions =>
// URL of that page) and the relative path to the root as given to it by the
// backend. Using these two we can determine the true absolute root.
const url = new URL(
req.query.base || req.body.base || "/",
req.query.href || req.body.href || "http://" + (req.headers.host || "localhost"),
req.query.base || req.body?.base || "/",
req.query.href || req.body?.href || "http://" + (req.headers.host || "localhost"),
)
return {
domain: getCookieDomain(url.host, req.args["proxy-domain"]),