worker: proxy /archive paths to replay origin
This commit is contained in:
parent
b570175e35
commit
ee8c0b50d5
1 changed files with 4 additions and 2 deletions
|
|
@ -108,7 +108,7 @@ export default {
|
||||||
|
|
||||||
// Archive replay proxy. Forwards website requests to an archive replay origin
|
// Archive replay proxy. Forwards website requests to an archive replay origin
|
||||||
// (typically forge running `ec-node wt-archive-serve`).
|
// (typically forge running `ec-node wt-archive-serve`).
|
||||||
if (url.pathname.startsWith("/api/archive/")) {
|
if (url.pathname.startsWith("/api/archive/") || url.pathname.startsWith("/archive/")) {
|
||||||
const origin = env.EC_ARCHIVE_ORIGIN?.trim();
|
const origin = env.EC_ARCHIVE_ORIGIN?.trim();
|
||||||
if (!origin) {
|
if (!origin) {
|
||||||
return jsonNoStore({ error: "archive origin not configured" }, { status: 503 });
|
return jsonNoStore({ error: "archive origin not configured" }, { status: 503 });
|
||||||
|
|
@ -120,7 +120,9 @@ export default {
|
||||||
return jsonNoStore({ error: "invalid archive origin" }, { status: 500 });
|
return jsonNoStore({ error: "invalid archive origin" }, { status: 500 });
|
||||||
}
|
}
|
||||||
const target = new URL(base.toString());
|
const target = new URL(base.toString());
|
||||||
const suffix = url.pathname.slice("/api/archive".length);
|
const suffix = url.pathname.startsWith("/api/archive/")
|
||||||
|
? url.pathname.slice("/api/archive".length)
|
||||||
|
: url.pathname.slice("/archive".length);
|
||||||
target.pathname = `${base.pathname.replace(/\/$/, "")}/archive${suffix}`;
|
target.pathname = `${base.pathname.replace(/\/$/, "")}/archive${suffix}`;
|
||||||
target.search = url.search;
|
target.search = url.search;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue