'How to set req.body for a video tag?

I would like to set a req.body parameter for the request that the video tag is requesting.

The Video tag requests at a certain route to request a video stream. However I would like to send the path of the video through without it being seen in the Url bar. This is why I cannot put it as a parameter of the url.

How would I set the path of the video as a req.body.filepath in a video tag?

Here is the Video tag

<video src="/video/play/" height="70%" width="auto" controls autoplay style="display:block;margin:180px auto">

Here is the video route

router.get("/video/play/", function (req, res) {

    const path = req.body.filepath
    const stat = fs.statSync(path);
    const fileSize = stat.size;
    const range = req.headers.range;
    if (range) {
        
        const parts = range.replace(/bytes=/, "").split("-")
        const start = parseInt(parts[0], 10)
        const end = parts[1]
            ? parseInt(parts[1], 10)
            : fileSize - 1
        const chunksize = (end - start) + 1
        const file = fs.createReadStream(path, { start, end })
        const head = {
            'Content-Range': `bytes ${start}-${end}/${fileSize}`,
            'Accept-Ranges': 'bytes',
            'Content-Length': chunksize,
            'Content-Type': 'video/quicktime'
        }
        res.writeHead(206, head);
        file.pipe(res);
    } else {
        const head = {
            'Content-Length': fileSize,
            'Content-Type': 'video/quicktime',
        }
        res.writeHead(206, head)
        fs.createReadStream(path).pipe(res)
    }
})


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source