From 83820c395109f84673d15cc775213cd8ef74b480 Mon Sep 17 00:00:00 2001 From: caadiq Date: Tue, 23 Dec 2025 16:35:22 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=AA=A8=EB=93=9C=ED=8C=A9=20=EB=8B=A4?= =?UTF-8?q?=EC=9A=B4=EB=A1=9C=EB=93=9C=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - GET /api/modpacks/:id/download: S3 URL로 리디렉션 --- backend/routes/api.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/backend/routes/api.js b/backend/routes/api.js index df9f445..9d2a8be 100644 --- a/backend/routes/api.js +++ b/backend/routes/api.js @@ -134,4 +134,27 @@ router.get("/modpacks", async (req, res) => { } }); +// 모드팩 다운로드 API (S3 리디렉션) +router.get("/modpacks/:id/download", async (req, res) => { + try { + const { id } = req.params; + + const [rows] = await dbPool.query(`SELECT * FROM modpacks WHERE id = ?`, [ + id, + ]); + if (rows.length === 0) { + return res.status(404).json({ error: "모드팩을 찾을 수 없습니다" }); + } + + const modpack = rows[0]; + const downloadUrl = `https://s3.caadiq.co.kr/minecraft/${modpack.file_key}`; + + // Content-Disposition 헤더로 파일명 지정하여 리디렉션 + res.redirect(downloadUrl); + } catch (error) { + console.error("[API] 모드팩 다운로드 실패:", error.message); + res.status(500).json({ error: "다운로드 실패" }); + } +}); + export default router;