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

@@ -68,8 +68,8 @@ router.get("/", async (req, res) => {
res.send(await getRoot(req))
})
router.post<{}, string, { password: string; base?: string }, { to?: string }>("/", async (req, res) => {
const password = sanitizeString(req.body.password)
router.post<{}, string, { password?: string; base?: string } | undefined, { to?: string }>("/", async (req, res) => {
const password = sanitizeString(req.body?.password)
const hashedPasswordFromArgs = req.args["hashed-password"]
try {