fix crash in case database entry is malformed
This commit is contained in:
@@ -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 => {
|
||||||
|
|||||||
Reference in New Issue
Block a user