app.use("/static", (req, res, next) => { const fileExtension = req.path.substr(req.path.lastIndexOf(".")); if (req.get("Accept") && req.get("Accept").includes("image/webp") && req.path.startsWith("/img") && ![".gif", ".webp"].includes(fileExtension)) { res.redirect(`/static${req.path.substring(0, req.path.lastIndexOf("."))}.webp`); } else { return staticRouter(req, res, next); } });