warren-bank / HLS-Proxy

Node.js server to proxy HLS video streams
http://webcast-reloaded.surge.sh/proxy.html
GNU General Public License v2.0
257 stars 80 forks source link

URL path prefix works only if it contains dash #55

Open ed-asriyan opened 3 months ago

ed-asriyan commented 3 months ago

Based on https://github.com/warren-bank/HLS-Proxy/issues/37#issuecomment-1808952022.

How to reproduce:

  1. Run hlsd -v 3 --host "example.com:443" --port 8080
  2. Make request http://localhost:8080/smth/{base64}.m3u8

Actual result: 400 bad request

Expected result: HLS file with links containing https://example.com:443/smth/....

However, if you make request with dash inside the URL path prefix, for example http://localhost:8080/smt-h/{base64}.m3u8, it works as expected

warren-bank commented 3 months ago

off-hand, I'd guess that the comment made for major version 2.x regarding the Express.js route is relevant to your usage.. since smth/ are all valid base64 characters.. and by inserting - (or any other character that isn't valid for base64 encoding) would cause the path up to and including the directory containing this invalid character to be excluded.. and the base64 string would begin following the next / character.

note: using v3.x with Express.js can workaround this limitation.

aside: using a URL-safe base64 charset would've made life simpler.. hindsight; I'm probably locked in at this point.

warren-bank commented 3 months ago

relevant code:

https://github.com/warren-bank/HLS-Proxy/blob/v3.5.4/hls-proxy/utils.js#L5 https://github.com/warren-bank/HLS-Proxy/blob/v3.5.4/hls-proxy/utils.js#L24 https://github.com/warren-bank/HLS-Proxy/blob/v3.5.4/hls-proxy/utils.js#L27