instead of
return res.status(401).json({ error: "User must sign in" })
write
res.status(401).json({ error: "User must sign in" }); return;