fix: Embedded PDF rendering in Safari (#11107)

This commit is contained in:
Tom Moor
2026-01-07 21:59:12 -05:00
committed by GitHub
parent eb0ac044a0
commit 974c5f9f70
2 changed files with 13 additions and 3 deletions
+9 -1
View File
@@ -102,7 +102,15 @@ router.get(
ctx.set("Access-Control-Allow-Origin", "*");
ctx.set("Cache-Control", cacheHeader);
ctx.set("Content-Type", contentType);
ctx.set("Content-Security-Policy", "sandbox");
ctx.set(
"Content-Security-Policy",
// Safari will not render PDFs in an embed if the sandbox directive is used, so we use a
// tight CSP in that case. For all other file types we use the strict sandbox directive
// which blocks all content from being loaded and rendered.
contentType === "application/pdf"
? "default-src 'self'; object-src 'self'; base-uri 'none';"
: "sandbox"
);
ctx.set(
"Content-Disposition",
contentDisposition(fileName, {
+4 -2
View File
@@ -111,8 +111,10 @@ export default function PdfViewer(props: Props) {
title={name}
src={href}
ref={embedRef}
type="application/pdf"
width={width}
width={
// subtract padding and borders from width
width - 24
}
height={height}
style={{
pointerEvents: