diff --git a/CloudServer/server.js b/CloudServer/server.js index 4b102bf..7c67dd1 100644 --- a/CloudServer/server.js +++ b/CloudServer/server.js @@ -148,44 +148,50 @@ function safeRelativeToBase(baseDir, relativePath) { return full; } -app.get('/media/audio/general/:relPath(.*)', (req, res) => { - const rel = req.params.relPath || ''; +app.use('/media/audio/general', express.static(getBeepAudioDirs(), { fallthrough: true })); +app.use('/media/audio/beep', express.static(getBeepAudioDirs(), { fallthrough: true })); +app.use('/media/audio/music', express.static(audioMusicDir, { fallthrough: true })); +app.use('/media/audio/voice', express.static(audioVoiceDir, { fallthrough: true })); +app.use('/media/audio/line', express.static(audioLineDir, { fallthrough: true })); +app.use('/media/audio/station', express.static(audioStationDir, { fallthrough: true })); +app.use('/media/temp', express.static(tempBroadcastDir, { fallthrough: true })); + +app.get('/media/audio/general/:path(*)', (req, res) => { + const rel = decodeURIComponent(req.params.path || ''); const candidates = getBeepAudioDirs().map(dir => safeRelativeToBase(dir, rel)).filter(Boolean); sendBinaryFileFromCandidates(res, candidates); }); -app.get('/media/audio/beep/:relPath(.*)', (req, res) => { - const rel = req.params.relPath || ''; +app.get('/media/audio/beep/:path(*)', (req, res) => { + const rel = decodeURIComponent(req.params.path || ''); const candidates = getBeepAudioDirs().map(dir => safeRelativeToBase(dir, rel)).filter(Boolean); sendBinaryFileFromCandidates(res, candidates); }); -app.get('/media/audio/music/:relPath(.*)', (req, res) => { - const rel = req.params.relPath || ''; +app.get('/media/audio/music/:path(*)', (req, res) => { + const rel = decodeURIComponent(req.params.path || ''); const full = safeRelativeToBase(audioMusicDir, rel); if (!full) return res.status(404).end(); sendBinaryFile(res, full); }); -app.get('/media/audio/voice/:relPath(.*)', (req, res) => { - const rel = req.params.relPath || ''; +app.get('/media/audio/voice/:path(*)', (req, res) => { + const rel = decodeURIComponent(req.params.path || ''); const full = safeRelativeToBase(audioVoiceDir, rel); if (!full) return res.status(404).end(); sendBinaryFile(res, full); }); -app.get('/media/audio/line/:relPath(.*)', (req, res) => { - const rel = req.params.relPath || ''; +app.get('/media/audio/line/:path(*)', (req, res) => { + const rel = decodeURIComponent(req.params.path || ''); const full = safeRelativeToBase(audioLineDir, rel); if (!full) return res.status(404).end(); sendBinaryFile(res, full); }); - -app.get('/media/audio/station/:relPath(.*)', (req, res) => { - const rel = req.params.relPath || ''; +app.get('/media/audio/station/:path(*)', (req, res) => { + const rel = decodeURIComponent(req.params.path || ''); const full = safeRelativeToBase(audioStationDir, rel); if (!full) return res.status(404).end(); sendBinaryFile(res, full); }); - -app.get('/media/temp/:relPath(.*)', (req, res) => { - const rel = req.params.relPath || ''; +app.get('/media/temp/:path(*)', (req, res) => { + const rel = decodeURIComponent(req.params.path || ''); 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 d455c29..2dd1ddc 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1,6 +1,6 @@ -- 1. Configuration & Constants -local APP_VERSION_TEXT = "v1.0.101" +local APP_VERSION_TEXT = "v1.0.102" local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group",