fix: 修复新版 path-to-regexp 不兼容 '*' 通配符导致启动崩溃
新版 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
This commit is contained in:
+14
-14
@@ -148,44 +148,44 @@ function safeRelativeToBase(baseDir, relativePath) {
|
|||||||
return full;
|
return full;
|
||||||
}
|
}
|
||||||
|
|
||||||
app.get('/media/audio/general/*', (req, res) => {
|
app.get('/media/audio/general/:relPath(.*)', (req, res) => {
|
||||||
const rel = req.params[0] || '';
|
const rel = req.params.relPath || '';
|
||||||
const candidates = getBeepAudioDirs().map(dir => safeRelativeToBase(dir, rel)).filter(Boolean);
|
const candidates = getBeepAudioDirs().map(dir => safeRelativeToBase(dir, rel)).filter(Boolean);
|
||||||
sendBinaryFileFromCandidates(res, candidates);
|
sendBinaryFileFromCandidates(res, candidates);
|
||||||
});
|
});
|
||||||
app.get('/media/audio/beep/*', (req, res) => {
|
app.get('/media/audio/beep/:relPath(.*)', (req, res) => {
|
||||||
const rel = req.params[0] || '';
|
const rel = req.params.relPath || '';
|
||||||
const candidates = getBeepAudioDirs().map(dir => safeRelativeToBase(dir, rel)).filter(Boolean);
|
const candidates = getBeepAudioDirs().map(dir => safeRelativeToBase(dir, rel)).filter(Boolean);
|
||||||
sendBinaryFileFromCandidates(res, candidates);
|
sendBinaryFileFromCandidates(res, candidates);
|
||||||
});
|
});
|
||||||
app.get('/media/audio/music/*', (req, res) => {
|
app.get('/media/audio/music/:relPath(.*)', (req, res) => {
|
||||||
const rel = req.params[0] || '';
|
const rel = req.params.relPath || '';
|
||||||
const full = safeRelativeToBase(audioMusicDir, rel);
|
const full = safeRelativeToBase(audioMusicDir, rel);
|
||||||
if (!full) return res.status(404).end();
|
if (!full) return res.status(404).end();
|
||||||
sendBinaryFile(res, full);
|
sendBinaryFile(res, full);
|
||||||
});
|
});
|
||||||
app.get('/media/audio/voice/*', (req, res) => {
|
app.get('/media/audio/voice/:relPath(.*)', (req, res) => {
|
||||||
const rel = req.params[0] || '';
|
const rel = req.params.relPath || '';
|
||||||
const full = safeRelativeToBase(audioVoiceDir, rel);
|
const full = safeRelativeToBase(audioVoiceDir, rel);
|
||||||
if (!full) return res.status(404).end();
|
if (!full) return res.status(404).end();
|
||||||
sendBinaryFile(res, full);
|
sendBinaryFile(res, full);
|
||||||
});
|
});
|
||||||
app.get('/media/audio/line/*', (req, res) => {
|
app.get('/media/audio/line/:relPath(.*)', (req, res) => {
|
||||||
const rel = req.params[0] || '';
|
const rel = req.params.relPath || '';
|
||||||
const full = safeRelativeToBase(audioLineDir, rel);
|
const full = safeRelativeToBase(audioLineDir, rel);
|
||||||
if (!full) return res.status(404).end();
|
if (!full) return res.status(404).end();
|
||||||
sendBinaryFile(res, full);
|
sendBinaryFile(res, full);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/media/audio/station/*', (req, res) => {
|
app.get('/media/audio/station/:relPath(.*)', (req, res) => {
|
||||||
const rel = req.params[0] || '';
|
const rel = req.params.relPath || '';
|
||||||
const full = safeRelativeToBase(audioStationDir, rel);
|
const full = safeRelativeToBase(audioStationDir, rel);
|
||||||
if (!full) return res.status(404).end();
|
if (!full) return res.status(404).end();
|
||||||
sendBinaryFile(res, full);
|
sendBinaryFile(res, full);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/media/temp/*', (req, res) => {
|
app.get('/media/temp/:relPath(.*)', (req, res) => {
|
||||||
const rel = req.params[0] || '';
|
const rel = req.params.relPath || '';
|
||||||
const full = safeRelativeToBase(tempBroadcastDir, rel);
|
const full = safeRelativeToBase(tempBroadcastDir, rel);
|
||||||
if (!full) return res.status(404).end();
|
if (!full) return res.status(404).end();
|
||||||
sendBinaryFile(res, full);
|
sendBinaryFile(res, full);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
-- 1. Configuration & Constants
|
-- 1. Configuration & Constants
|
||||||
local APP_VERSION_TEXT = "v1.0.100"
|
local APP_VERSION_TEXT = "v1.0.101"
|
||||||
|
|
||||||
local CONFIG = {
|
local CONFIG = {
|
||||||
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
||||||
|
|||||||
Reference in New Issue
Block a user