fix crash in case database entry is malformed

This commit is contained in:
Enstrayed
2024-05-02 17:36:54 -07:00
parent 7a5593607e
commit 544f1fb017

View File

@@ -10,7 +10,12 @@ app.get("/etyd*", (rreq,rres) => {
rres.sendStatus(404) rres.sendStatus(404)
} else { } else {
dbRes.json().then(dbRes => { dbRes.json().then(dbRes => {
rres.redirect(dbRes.content.url) try {
rres.redirect(dbRes.content.url) // Node will crash if the Database entry is malformed
} catch (responseError) {
rres.sendStatus(500)
console.log(`${rres.get("cf-connecting-ip")} GET ${rreq.path} returned 500: ${responseError}`)
}
}) })
} }
}).catch(fetchError => { }).catch(fetchError => {