Changeset f2eacca in Klonkt for src/routes/audio.js
- Timestamp:
- 06/30/2026 01:50:00 AM (2 months ago)
- Branches:
- main
- Children:
- 084d1c0
- Parents:
- 80797d7
- File:
-
- 1 edited
-
src/routes/audio.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/audio.js
r80797d7 rf2eacca 54 54 }; 55 55 56 // Access gate: allow only same-origin browser fetches / media loads.57 function isAllowedAudioRequest(req ) {56 // Access gate: same-origin browser fetches / media loads — PLUS fediverse-shared tracks. 57 function isAllowedAudioRequest(req, filename) { 58 58 if (req.get('X-Audio-Player') === '1') return true; // our blob fetch 59 59 const site = req.get('Sec-Fetch-Site'); // set by modern browsers 60 return site === 'same-origin' || site === 'same-site'; 60 if (site === 'same-origin' || site === 'same-site') return true; 61 // fedi_open tracks are deliberately served ungated so remote servers (Mastodon, …) can 62 // fetch + play the file inline. The operator opted this specific track in (per-track flag). 63 if (filename) { 64 try { 65 const r = db.prepare(`SELECT 1 FROM audio_tracks t JOIN media m ON t.media_id = m.id 66 WHERE t.fedi_open = 1 AND (m.storage_path = ? OR m.storage_path LIKE ?) LIMIT 1`).get(filename, '%' + filename); 67 if (r) return true; 68 } catch { /* ignore */ } 69 } 70 return false; 61 71 } 62 72 … … 64 74 const { filename } = req.params; 65 75 66 if (!isAllowedAudioRequest(req )) {76 if (!isAllowedAudioRequest(req, filename)) { 67 77 return res.status(403).send('Direct access not allowed'); 68 78 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)