The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
fix(web): the preview only embeds PDFs from its own environment (#39497)
Julius Marminge committed
Nov 19, 2026 at 19:47 UTC
20b8a9e695c98379ac6baf725173587044eaee83
3 files changed
+11
-4
apps/web/src/browser/serverPictureInPicture.ts
+6
-1
@@ -9,6 +9,7 @@ import { previewPdfAssetUrl } from "@t3tools/shared/preview";
9
import { useSyncExternalStore } from "react";
10
11
import { readPreviewStreamAccess } from "~/state/previewStream";
12
+import { readPreparedConnection } from "~/state/session";
13
import { previewStateAtom, type ThreadPreviewState } from "~/previewStateStore";
14
import { appAtomRegistry } from "~/rpc/atomRegistry";
15
@@ -185,7 +186,11 @@ export async function openServerPictureInPicture(input: {
186
const navigation = state.sessions[input.tabId]?.navStatus;
187
if (
188
navigation?._tag === "Success" &&
188
- previewPdfAssetUrl(navigation.url, navigation.url) !== null
189
+ // The base the client loads asset PDFs through now; a connection can change route.
190
+ previewPdfAssetUrl(
191
+ navigation.url,
192
+ readPreparedConnection(input.environmentId)?.httpBaseUrl ?? null,
193
+ ) !== null
194
) {
195
onLeave();
196
}
packages/shared/src/preview.test.ts
+2
-2
@@ -32,10 +32,10 @@ describe("previewPdfAssetUrl", () => {
32
});
33
34
it.each(["another-environment.test", "127.0.0.2.example.com", "128.0.0.1"])(
35
- "preserves matching PDF URLs on unrelated host %s",
35
+ "leaves a matching PDF path on unrelated host %s on its browser session",
36
(host) => {
37
const source = `https://${host}/api/assets/token/guide.pdf?revision=2#page=3`;
38
- expect(previewPdfAssetUrl(source, "https://environment.test")).toBe(source);
38
+ expect(previewPdfAssetUrl(source, "https://environment.test")).toBeNull();
39
},
40
);
41
packages/shared/src/preview.ts
+3
-1
@@ -18,12 +18,14 @@ export function previewPdfAssetUrl(rawUrl: string, httpBaseUrl: string | null):
18
) {
19
return null;
20
}
21
+ // Any site can serve a page at this path; one the client embedded would run in the user's
22
+ // own browser instead of the preview's. Only this environment's assets are loaded here.
23
if (
24
url.origin !== baseUrl.origin &&
25
!isLocalLoopbackHost(url.hostname) &&
26
url.hostname !== "0.0.0.0"
27
) {
26
- return url.href;
28
+ return null;
29
}
30
// The browser may run on the host's loopback address. Fetch signed bytes
31
// through this client's environment connection, including remote routes.