@tokenoftrust/storefront-runner 6.11.10 → 6.11.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -159,6 +159,8 @@ declare global {
159
159
  * the pinned render.
160
160
  */
161
161
  apiBasePath: string;
162
+ /** Captured-image prefix from tenant routing (`TenantRouting.imageBasePath`); absent when root `/_a/` reaches the tenant. */
163
+ imageBasePath?: string;
162
164
  /**
163
165
  * The origin the viewer addressed: `https://<viewer host>` for an
164
166
  * authenticated CDN forward (ADR 0013 Tier 3), else the request URL's own
@@ -28,6 +28,11 @@ export interface TenantRouting {
28
28
  basePath: string;
29
29
  /** Route to render with the tenant prefix stripped (leading slash, no query). */
30
30
  renderPath: string;
31
+ /**
32
+ * Prefix that keeps captured-image (`/_a/...`) requests on {@link tenant}, set only when the tenant
33
+ * came from an embedded path segment on a host that routes root paths to a different tenant.
34
+ */
35
+ imageBasePath?: string;
31
36
  }
32
37
 
33
38
  /** Keep preview navigation on its session host whenever that host can route the target. */
@@ -154,6 +159,7 @@ export async function resolveTenantRouting(
154
159
  tenant: byEmbedded,
155
160
  basePath: "",
156
161
  renderPath: normalizePath(pathname),
162
+ imageBasePath: `/${embedded}`,
157
163
  };
158
164
  }
159
165
  }
@@ -45,7 +45,7 @@ export function prefixPreviewPinnedImageUrls(html: string, basePath: string): st
45
45
  /** Choose asset routing from the resolved request tenant, never a second host-membership check. */
46
46
  export function previewPinnedImageBasePath(tenant: {
47
47
  tenant_id: string; appDomain?: string;
48
- }, routing: { tenantId: string | undefined; basePath: string }): string {
49
- if (routing.tenantId === tenant.tenant_id) return routing.basePath;
48
+ }, routing: { tenantId: string | undefined; basePath: string; imageBasePath?: string }): string {
49
+ if (routing.tenantId === tenant.tenant_id) return routing.imageBasePath ?? routing.basePath;
50
50
  return tenant.appDomain && /^[a-z0-9.-]+$/i.test(tenant.appDomain) ? `/${tenant.appDomain}` : "";
51
51
  }
@@ -191,7 +191,7 @@ async function serveRequest(
191
191
  // Host first; if the host owns no tenant, a leading /<domain>/ path segment
192
192
  // selects one (DNS-free tenant selection on localhost/preview). The resolver
193
193
  // is KV-backed in prod (many-tenant) and static in plain dev.
194
- const { tenant, basePath, renderPath } = await timing.time("tenant", async () => {
194
+ const { tenant, basePath, renderPath, imageBasePath } = await timing.time("tenant", async () => {
195
195
  const resolver = await getTenantResolver();
196
196
  return cdn
197
197
  ? await resolveCdnForwardRouting(cdn, url.pathname, resolver)
@@ -201,6 +201,7 @@ async function serveRequest(
201
201
  return new Response("Unknown host", { status: 404 });
202
202
  }
203
203
  seen.assetBasePath = basePath;
204
+ if (imageBasePath) context.locals.imageBasePath = imageBasePath;
204
205
 
205
206
  // ---- The one route classification -----------------------------------------
206
207
  // An EXPLICITLY unpaid store is never fully public: the ONLY way to reach its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "6.11.10",
3
+ "version": "6.11.11",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
6
6
  "packageManager": "pnpm@11.9.0",