diff --git a/src/lib/components/onboarding/GuidedTour.svelte b/src/lib/components/onboarding/GuidedTour.svelte
index 3056d13b3..4ab652d1d 100644
--- a/src/lib/components/onboarding/GuidedTour.svelte
+++ b/src/lib/components/onboarding/GuidedTour.svelte
@@ -61,6 +61,7 @@
diff --git a/src/routes/(app)/documents/[id]-[slug]/+page.server.ts b/src/routes/(app)/documents/[id]-[slug]/+page.server.ts
index 7b34e13c2..5dd64610b 100644
--- a/src/routes/(app)/documents/[id]-[slug]/+page.server.ts
+++ b/src/routes/(app)/documents/[id]-[slug]/+page.server.ts
@@ -4,12 +4,21 @@ import type { Access, Document, Note } from "$lib/api/types";
import { fail } from "@sveltejs/kit";
import { setFlash, redirect } from "sveltekit-flash-message/server";
-import { CSRF_COOKIE_NAME } from "@/config/config.js";
+import { CSRF_COOKIE_NAME, EMBED_URL } from "@/config/config.js";
import { destroy, edit, redact } from "$lib/api/documents";
import * as notes from "$lib/api/notes";
import { isErrorCode } from "$lib/utils/api";
-export function load({ cookies }) {
+export function load({ cookies, request, url }) {
+ const inIframe = request.headers.get("Sec-Fetch-Dest") === "iframe";
+ if (inIframe) {
+ const embed = new URL(url);
+
+ embed.host = new URL(EMBED_URL).host;
+ embed.searchParams.set("embed", "1");
+ return redirect(307, embed);
+ }
+
const csrf_token = cookies.get(CSRF_COOKIE_NAME);
return { csrf_token };
diff --git a/src/routes/(app)/documents/[id]-[slug]/+page.svelte b/src/routes/(app)/documents/[id]-[slug]/+page.svelte
index 9b54910e6..cf3d12b2b 100644
--- a/src/routes/(app)/documents/[id]-[slug]/+page.svelte
+++ b/src/routes/(app)/documents/[id]-[slug]/+page.svelte
@@ -3,10 +3,11 @@
-->
diff --git a/src/routes/(app)/documents/[id]-[slug]/+page.ts b/src/routes/(app)/documents/[id]-[slug]/+page.ts
index 74a94e72b..5de05fc47 100644
--- a/src/routes/(app)/documents/[id]-[slug]/+page.ts
+++ b/src/routes/(app)/documents/[id]-[slug]/+page.ts
@@ -20,6 +20,7 @@ export async function load({
depends,
url,
setHeaders,
+ data,
}) {
const { document, asset_url, mode } = await loadDocument({
fetch,
@@ -55,6 +56,7 @@ export async function load({
}
return {
+ ...data,
document,
mode,
asset_url,
diff --git a/src/routes/embed/+layout.ts b/src/routes/embed/+layout.ts
index 1b8871cca..cd315a431 100644
--- a/src/routes/embed/+layout.ts
+++ b/src/routes/embed/+layout.ts
@@ -1 +1 @@
-export const trailingSlash = "always";
+export const trailingSlash = "ignore";