fix whep player
This commit is contained in:
@@ -157,7 +157,17 @@ export function useWhepPlayer({
|
||||
const location = res.headers.get("location") || res.headers.get("Location");
|
||||
if (location) {
|
||||
try {
|
||||
sessionUrlRef.current = new URL(location, whepUrl).toString();
|
||||
const baseUrl = new URL(whepUrl);
|
||||
if (location.startsWith("/")) {
|
||||
// MediaMTX can return absolute paths like "/cam1/whep/<id>".
|
||||
// If WHEP is behind a prefix (e.g. "/mtx"), preserve that prefix for DELETE.
|
||||
const parts = baseUrl.pathname.split("/").filter(Boolean);
|
||||
const prefix = parts.slice(0, -2).join("/");
|
||||
const normalized = prefix ? `/${prefix}${location}` : location;
|
||||
sessionUrlRef.current = new URL(normalized, baseUrl.origin).toString();
|
||||
} else {
|
||||
sessionUrlRef.current = new URL(location, whepUrl).toString();
|
||||
}
|
||||
} catch {
|
||||
sessionUrlRef.current = location;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user