From 4b46c8d57715334e13bd7ba808be5c518bf62595 Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Tue, 18 Aug 2026 16:41:16 -0400 Subject: [PATCH] Serve document bytes, not the app shell, to / loads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An / load is issued as a frame-style navigation whose Accept header includes text/html, and the realm serves the host app for any HTML-accepting request — so an embedded PDF viewer received the app shell and booted the app recursively inside the preview. No client-side layer can correct this: the ServiceWorker spec makes / requests fall back to the network without dispatching a fetch event. Browsers do stamp Sec-Fetch-Dest on these loads (on trustworthy origins), so serveIndex/serveHostApp now decline to serve the shell when it is embed or object and fall through to the realm, which serves the file's own bytes. Address-bar navigations (Sec-Fetch-Dest: document, or absent) keep opening the app, and cacheable shell responses vary on Sec-Fetch-Dest so a cached shell can never satisfy an embed load. Co-Authored-By: Claude Fable 5 --- packages/base/file-formats/pdf-viewer.gts | 8 +- packages/realm-server/handlers/serve-index.ts | 29 +++++++ .../server-endpoints/index-responses-test.ts | 86 +++++++++++++++++++ 3 files changed, 121 insertions(+), 2 deletions(-) diff --git a/packages/base/file-formats/pdf-viewer.gts b/packages/base/file-formats/pdf-viewer.gts index a0041519d53..f285400e08d 100644 --- a/packages/base/file-formats/pdf-viewer.gts +++ b/packages/base/file-formats/pdf-viewer.gts @@ -16,8 +16,12 @@ import { FileObject } from './file-resources'; import type { FilePreviewSignature } from './file-preview-stage'; export class PdfViewer extends GlimmerComponent { - // The served document URL. The auth service worker injects the realm token on - // the native `` request, the same path ``/`