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:
@@ -1068,7 +1068,7 @@ async function handleApi(req,res,pathname){
|
|||||||
//
|
//
|
||||||
// Range support is not optional here: without it the browser cannot seek, so
|
// Range support is not optional here: without it the browser cannot seek, so
|
||||||
// the scrub bar looks present but does nothing.
|
// 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 slug=pathname.slice(4).replace(/\.mp4$/,'');
|
||||||
const vfile=path.join(DATA_DIR,'tool-videos',slug+'.mp4');
|
const vfile=path.join(DATA_DIR,'tool-videos',slug+'.mp4');
|
||||||
let st=null;
|
let st=null;
|
||||||
@@ -1088,6 +1088,7 @@ async function handleApi(req,res,pathname){
|
|||||||
return fs.createReadStream(vfile,{start,end}).pipe(res);
|
return fs.createReadStream(vfile,{start,end}).pipe(res);
|
||||||
}
|
}
|
||||||
res.writeHead(200,securityHeaders(Object.assign({},base,{'Content-Length':st.size})));
|
res.writeHead(200,securityHeaders(Object.assign({},base,{'Content-Length':st.size})));
|
||||||
|
if(req.method==='HEAD')return res.end();
|
||||||
return fs.createReadStream(vfile).pipe(res);
|
return fs.createReadStream(vfile).pipe(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user