diff --git a/server/index.js b/server/index.js index 6f3f02d..2c72759 100644 --- a/server/index.js +++ b/server/index.js @@ -642,9 +642,8 @@ app.post("/api/licenses/verify", async (req, res) => { } }); -app.post("/api/licenses/download", async (req, res) => { +async function handleLicenseDownload(res, { key, hostname, version = "latest" }) { try { - const { key, hostname, version = "latest" } = req.body || {}; if (!key || !hostname) { return res.status(400).json({ error: "Licentiecode en hostname zijn verplicht." }); } @@ -685,6 +684,22 @@ app.post("/api/licenses/download", async (req, res) => { res.end(); } } +} + +app.post("/api/licenses/download", async (req, res) => { + await handleLicenseDownload(res, { + key: req.body?.key, + hostname: req.body?.hostname, + version: req.body?.version || "latest" + }); +}); + +app.get("/api/licenses/download", async (req, res) => { + await handleLicenseDownload(res, { + key: req.query.key, + hostname: req.query.hostname, + version: req.query.version || "latest" + }); }); app.use(express.static(PATHS.distDir));