From fc66e433791f5cafa633db76f519e6a242f44398 Mon Sep 17 00:00:00 2001 From: HenryDu8133 <813367384@qq.com> Date: Mon, 17 Aug 2026 15:38:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=B0=E7=89=88=20p?= =?UTF-8?q?ath-to-regexp=20=E4=B8=8D=E5=85=BC=E5=AE=B9=20'*'=20=E9=80=9A?= =?UTF-8?q?=E9=85=8D=E7=AC=A6=E5=AF=BC=E8=87=B4=E5=90=AF=E5=8A=A8=E5=B4=A9?= =?UTF-8?q?=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新版 express/router 依赖的 path-to-regexp 不再接受裸 '*' 路径语法, 改为命名通配参数 :relPath(.*),并同步把 req.params[0] 改为 req.params.relPath。涉及 7 条 /media/* 静态路由: - /media/audio/general/* - /media/audio/beep/* - /media/audio/music/* - /media/audio/voice/* - /media/audio/line/* - /media/audio/station/* - /media/temp/* 客户端版本号 bump v1.0.100 -> v1.0.101 --- CloudServer/server.js | 28 ++++++++++++++-------------- station_broadcast.lua | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CloudServer/server.js b/CloudServer/server.js index b11cea4..4b102bf 100644 --- a/CloudServer/server.js +++ b/CloudServer/server.js @@ -148,44 +148,44 @@ function safeRelativeToBase(baseDir, relativePath) { return full; } -app.get('/media/audio/general/*', (req, res) => { - const rel = req.params[0] || ''; +app.get('/media/audio/general/:relPath(.*)', (req, res) => { + const rel = req.params.relPath || ''; const candidates = getBeepAudioDirs().map(dir => safeRelativeToBase(dir, rel)).filter(Boolean); sendBinaryFileFromCandidates(res, candidates); }); -app.get('/media/audio/beep/*', (req, res) => { - const rel = req.params[0] || ''; +app.get('/media/audio/beep/:relPath(.*)', (req, res) => { + const rel = req.params.relPath || ''; const candidates = getBeepAudioDirs().map(dir => safeRelativeToBase(dir, rel)).filter(Boolean); sendBinaryFileFromCandidates(res, candidates); }); -app.get('/media/audio/music/*', (req, res) => { - const rel = req.params[0] || ''; +app.get('/media/audio/music/:relPath(.*)', (req, res) => { + const rel = req.params.relPath || ''; const full = safeRelativeToBase(audioMusicDir, rel); if (!full) return res.status(404).end(); sendBinaryFile(res, full); }); -app.get('/media/audio/voice/*', (req, res) => { - const rel = req.params[0] || ''; +app.get('/media/audio/voice/:relPath(.*)', (req, res) => { + const rel = req.params.relPath || ''; const full = safeRelativeToBase(audioVoiceDir, rel); if (!full) return res.status(404).end(); sendBinaryFile(res, full); }); -app.get('/media/audio/line/*', (req, res) => { - const rel = req.params[0] || ''; +app.get('/media/audio/line/:relPath(.*)', (req, res) => { + const rel = req.params.relPath || ''; const full = safeRelativeToBase(audioLineDir, rel); if (!full) return res.status(404).end(); sendBinaryFile(res, full); }); -app.get('/media/audio/station/*', (req, res) => { - const rel = req.params[0] || ''; +app.get('/media/audio/station/:relPath(.*)', (req, res) => { + const rel = req.params.relPath || ''; const full = safeRelativeToBase(audioStationDir, rel); if (!full) return res.status(404).end(); sendBinaryFile(res, full); }); -app.get('/media/temp/*', (req, res) => { - const rel = req.params[0] || ''; +app.get('/media/temp/:relPath(.*)', (req, res) => { + const rel = req.params.relPath || ''; const full = safeRelativeToBase(tempBroadcastDir, rel); if (!full) return res.status(404).end(); sendBinaryFile(res, full); diff --git a/station_broadcast.lua b/station_broadcast.lua index 0aea9b8..d455c29 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1,6 +1,6 @@ -- 1. Configuration & Constants -local APP_VERSION_TEXT = "v1.0.100" +local APP_VERSION_TEXT = "v1.0.101" local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group",