Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(web): redirect framed share navigations to embed player

Richie McIlroy110ba6c5f72e
diff --git a/apps/web/proxy.ts b/apps/web/proxy.ts
index 34ef67620..d5983c84d 100644
--- a/apps/web/proxy.ts
+++ b/apps/web/proxy.ts
@@ -4,6 +4,7 @@ import { buildEnv, serverEnv } from "@cap/env";
import { eq } from "drizzle-orm";
import { notFound } from "next/navigation";
import { type NextRequest, NextResponse, userAgent } from "next/server";
+import { getShareIframeRedirectUrl } from "@/lib/share-iframe-navigation";
const addHttps = (s?: string) => {
if (!s) return s;
@@ -38,6 +39,18 @@ export async function proxy(request: NextRequest) {
return response;
}
+ const shareIframeRedirectUrl = getShareIframeRedirectUrl({
+ method: request.method,
+ requestUrl: request.url,
+ fetchDestination: request.headers.get("sec-fetch-dest"),
+ });
+ if (shareIframeRedirectUrl) {
+ const response = NextResponse.redirect(shareIframeRedirectUrl);
+ response.headers.set("Cache-Control", "private, no-store");
+ response.headers.set("Vary", "Sec-Fetch-Dest");
+ return response;
+ }
+
const hostname = url.hostname;
if (buildEnv.NEXT_PUBLIC_IS_CAP !== "true") {