Files
hyperframes/packages/studio-server/src/index.ts
T
James RussoandClaude Opus 5.5 983e865ad7 fix(studio-server): thumbnail origin from the server, sandbox previews from other sites (#7492)
* fix(studio-server): thumbnail origin from the server, sandbox previews from other sites

The thumbnail route builds the headless browser's URL from the server's own
listening origin (a new optional `serverOrigin` on the adapter, wired in the CLI
preview server and the Vite dev host) instead of the request's Host header.
Hosts that report no origin fall back to a loopback Host only.

Preview responses (bundled, sub-composition and project files) opened from
another site carry `Content-Security-Policy: sandbox allow-scripts` and
`Vary: Sec-Fetch-Site`. Studio's same-origin iframe, browser automation and
non-browser clients are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(studio): build the thumbnail origin from a hostname bind name

With HYPERFRAMES_PREVIEW_HOST set to a hostname, the listening address is
the IP it resolved to, and the Host check accepts the bind name, not that
IP. The thumbnail browser then loaded a 403 page. Use the bind name when it
is a hostname; IP and wildcard binds keep the listening address.

— Rames Jusso

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* style(studio): drop the serverOrigin comment that put it over the package's comment share

The hostname-bind rule is stated by its test name in serverOrigin.test.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 14:30:10 +00:00

86 lines
3.0 KiB
TypeScript

export { createStudioApi, type StudioApiOptions } from "./createStudioApi.js";
export {
PREVIEW_ALLOWED_HOSTS_ENV,
previewAllowedHostsFromEnv,
} from "./helpers/requestIdentity.js";
export { MAX_UPLOAD_BYTES } from "./routes/files.js";
export {
createProjectSignature,
createProjectSignatureAsync,
affectsProjectSignature,
STUDIO_SIGNATURE_MANIFEST_PATHS,
} from "./helpers/projectSignature.js";
export { compositionsAffectedBy } from "./helpers/compositionInputs.js";
export { affectsPreview } from "./helpers/previewReads.js";
export * from "./history/index.js";
export { cleanupProxyCache } from "./helpers/proxyCache.js";
export { CACHE_DIR_NAME as PROXY_CACHE_DIR_NAME } from "./helpers/proxyTranscoder.js";
export type {
StudioApiAdapter,
ResolvedProject,
RenderJobState,
MediaProcessingJobState,
LintResult,
StudioSelectionResponse,
StudioSelectionSnapshot,
StudioSelectionTextField,
} from "./types.js";
export { isSafePath, walkDir } from "./helpers/safePath.js";
export { stampProjectHfIds, stampProjectHfIdsAsync } from "./helpers/hfIdPersist.js";
export {
patchElementInHtml,
splitElementInHtml,
removeElementFromHtml,
findTargetElement,
parseSourceDocument,
dedupeClonedCompositionId,
type PatchOperation,
type SourceMutationTarget,
} from "./helpers/sourceMutation.js";
export { duplicateElementInHtml, type DuplicateElementResult } from "./helpers/duplicateElement.js";
export {
applyFileMutations,
type AppliedFileMutation,
type FileMutationInput,
} from "./helpers/applyFileMutations.js";
export type { PreviewApiAdapter } from "./helpers/mediaProxyPreview.js";
export { PREVIEW_BUNDLE_OPTIONS } from "./routes/preview.js";
export { createPreviewDocumentStore } from "./helpers/previewDocumentStore.js";
export { getMimeType, MIME_TYPES } from "./helpers/mime.js";
export { decodeWellFormedEscapes, requestSubPath } from "./helpers/requestSubPath.js";
export { originForListeningAddress } from "./helpers/serverOrigin.js";
export { MAX_OPEN_MEDIA_RANGE_BYTES, openRangeEnd } from "./helpers/mediaRange.js";
export {
consumeFileWriteReceipt,
identifyFileWrite,
fileContentVersion,
DELETED_VERSION,
settledFileTag,
type FileWriteReceipt,
} from "./helpers/fileVersion.js";
export { buildSubCompositionHtml } from "./helpers/subComposition.js";
export {
clearElementScreenshotIsolation,
getElementScreenshotClip,
type ScreenshotClip,
} from "./helpers/screenshotClip.js";
export {
thumbnailDeviceScaleFactor,
type ThumbnailOutputDimensions,
} from "./helpers/thumbnailOutput.js";
export {
createBackgroundRemovalJob,
type BackgroundRemovalRender,
} from "./helpers/backgroundRemovalJob.js";
export {
STUDIO_MANUAL_EDITS_PATH,
createStudioManualEditsRenderBodyScript,
createStudioPositionSeekReapplyScript,
type StudioManualEditsRenderScriptOptions,
} from "./helpers/manualEditsRenderScript.js";
export {
STUDIO_MOTION_PATH,
createStudioMotionRenderBodyScript,
type StudioMotionRenderScriptOptions,
} from "./helpers/studioMotionRenderScript.js";