archive replay: add HLS DVR serve path and web mode
This commit is contained in:
parent
656ec11c73
commit
b35de70789
9 changed files with 904 additions and 26 deletions
|
|
@ -106,6 +106,35 @@ export default {
|
|||
return stub.fetch(request);
|
||||
}
|
||||
|
||||
// Archive replay proxy. Forwards website requests to an archive replay origin
|
||||
// (typically forge running `ec-node wt-archive-serve`).
|
||||
if (url.pathname.startsWith("/api/archive/")) {
|
||||
const origin = env.EC_ARCHIVE_ORIGIN?.trim();
|
||||
if (!origin) {
|
||||
return jsonNoStore({ error: "archive origin not configured" }, { status: 503 });
|
||||
}
|
||||
let base: URL;
|
||||
try {
|
||||
base = new URL(origin);
|
||||
} catch {
|
||||
return jsonNoStore({ error: "invalid archive origin" }, { status: 500 });
|
||||
}
|
||||
const target = new URL(base.toString());
|
||||
const suffix = url.pathname.slice("/api/archive".length);
|
||||
target.pathname = `${base.pathname.replace(/\/$/, "")}/archive${suffix}`;
|
||||
target.search = url.search;
|
||||
|
||||
const upstream = await fetch(new Request(target.toString(), request), {
|
||||
cf: { cacheTtl: 0, cacheEverything: false },
|
||||
});
|
||||
const headers = new Headers(upstream.headers);
|
||||
headers.set("cache-control", "no-store");
|
||||
return new Response(upstream.body, {
|
||||
status: upstream.status,
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
// Minimal bootstrap API: proxy /api/* to a single durable object instance ("global").
|
||||
// This exists only to rendezvous WebRTC offers/answers and list "live" entries.
|
||||
if (url.pathname.startsWith("/api/")) {
|
||||
|
|
@ -152,6 +181,7 @@ interface Env {
|
|||
EC_TURN_HOST?: string;
|
||||
EC_TURN_HMAC?: string;
|
||||
EC_STREAM_UPSERT_TOKEN?: string;
|
||||
EC_ARCHIVE_ORIGIN?: string;
|
||||
}
|
||||
|
||||
type DirectoryEntry = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue