Answer HEAD on /tv/ videos

The route matched GET only, so a HEAD probe fell through to the JSON
handler and 404'd. Some players issue HEAD before streaming; they would
have concluded the file did not exist.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-08-28 14:17:15 -05:00
parent 1896b707f8
commit 72529d0916
+2 -1
View File
@@ -1068,7 +1068,7 @@ async function handleApi(req,res,pathname){
//
// Range support is not optional here: without it the browser cannot seek, so
// the scrub bar looks present but does nothing.
if(req.method==='GET'&&/^\/tv\/[a-z0-9-]{1,60}\.mp4$/.test(pathname)){
if((req.method==='GET'||req.method==='HEAD')&&/^\/tv\/[a-z0-9-]{1,60}\.mp4$/.test(pathname)){
const slug=pathname.slice(4).replace(/\.mp4$/,'');
const vfile=path.join(DATA_DIR,'tool-videos',slug+'.mp4');
let st=null;
@@ -1088,6 +1088,7 @@ async function handleApi(req,res,pathname){
return fs.createReadStream(vfile,{start,end}).pipe(res);
}
res.writeHead(200,securityHeaders(Object.assign({},base,{'Content-Length':st.size})));
if(req.method==='HEAD')return res.end();
return fs.createReadStream(vfile).pipe(res);
}