diff --git a/server/src/meta.js b/server/src/meta.js index 69631de2..c21f17a9 100644 --- a/server/src/meta.js +++ b/server/src/meta.js @@ -353,7 +353,7 @@ module.exports = ({ app, Cache }) => { } async function getAllRedirects() { - return Promise.all((await Cache.get("Redirects"))?.ids?.map(id => Cache.get(id))); + return Promise.all(((await Cache.get("Redirects"))?.ids || []).map(id => Cache.get(id))); } async function getRedirect(path = "", subdomain) { diff --git a/server/src/routes.js b/server/src/routes.js index 561f3302..383ef0be 100644 --- a/server/src/routes.js +++ b/server/src/routes.js @@ -24,7 +24,7 @@ function niceJoin(array) { module.exports = ({ app, cors, Cache, io }) => { app.get("/redirect", async (req, res) => { try { - let redirects = (await Cache.get("Redirects"))?.items; + let redirects = await Promise.all(((await Cache.get("Redirects"))?.ids || []).map(id => Cache.get(id))); let subdomain = req.query.subdomain || null; let path = req.query.path; @@ -32,7 +32,7 @@ module.exports = ({ app, cors, Cache, io }) => { path = path.trim().toLowerCase(); - if (!redirects) return res.send({ redirect: null, warn: "no redirects loaded" }); + if (!redirects?.length) return res.send({ redirect: null, warn: "no redirects loaded" }); let redirect = redirects.find(r => { if (!r.active) return false;