Skip to content

Open source CapCut alternative.

TypeScript

feat(site): Cut-brand settings on donkeycut.com and keep API keys apex-only

David Le72f0e801603b
diff --git a/site/src/app/app/settings/SettingsShell.tsx b/site/src/app/app/settings/SettingsShell.tsx
index 2ffedc2b..cea6125b 100644
--- a/site/src/app/app/settings/SettingsShell.tsx
+++ b/site/src/app/app/settings/SettingsShell.tsx
@@ -4,6 +4,7 @@ import Link from "next/link";
import { usePathname, useRouter } from "next/navigation";
import { useEffect, type ReactNode } from "react";
+import { DONKEY_APEX_ORIGIN, isDonkeycutHost } from "@/cut/lib/hosts";
import { authClient } from "@/lib/auth-client";
import { cn } from "@/lib/utils";
import { Skeleton } from "@/components/ui/skeleton";
@@ -14,6 +15,15 @@ const navItems = [
{ href: "/app/settings/api-keys", label: "API keys" },
];
+// On donkeycut.com the same routes serve as Donkey Cut's settings: the Vision
+// API keys tab is Donkey-only (its page also redirects there), and sign-in must
+// go through the apex one-time-token handoff because Google OAuth cannot
+// complete on that domain (see /cut-auth). Reading window.location is safe from
+// hydration mismatch: everything host-dependent renders only after the client
+// session resolves.
+const onDonkeycut = () =>
+ typeof window !== "undefined" && isDonkeycutHost(window.location.host);
+
// The settings UI is fully client-rendered. We guard on the client session and,
// if signed out, send the user to Google sign-in (API routes also enforce auth).
export function SettingsShell({ children }: { children: ReactNode }) {
@@ -23,6 +33,12 @@ export function SettingsShell({ children }: { children: ReactNode }) {
useEffect(() => {
if (!isPending && !session) {
+ if (onDonkeycut()) {
+ window.location.assign(
+ `${DONKEY_APEX_ORIGIN}/cut-auth?next=${encodeURIComponent("/app/settings")}`,
+ );
+ return;
+ }
void authClient.signIn.social({
callbackURL: "/app/settings",
provider: "google",
@@ -53,10 +69,13 @@ export function SettingsShell({ children }: { children: ReactNode }) {
className="block h-full w-full object-contain"
/>
</div>
- <span>Donkey</span>
+ <span>{onDonkeycut() ? "Donkey Cut" : "Donkey"}</span>
</Link>
<nav className="flex items-center gap-1">
- {navItems.map((item) => (
+ {(onDonkeycut()
+ ? navItems.filter((item) => item.label !== "API keys")
+ : navItems
+ ).map((item) => (
<Link
key={item.href}
href={item.href}
diff --git a/site/src/app/app/settings/api-keys/page.tsx b/site/src/app/app/settings/api-keys/page.tsx
index 4620c155..7573f0ac 100644
--- a/site/src/app/app/settings/api-keys/page.tsx
+++ b/site/src/app/app/settings/api-keys/page.tsx
@@ -1,7 +1,13 @@
-"use client";
+import { headers } from "next/headers";
+import { redirect } from "next/navigation";
import { ApiKeysManager } from "@/app/app/settings/_components/ApiKeysManager";
+import { isDonkeycutHost } from "@/cut/lib/hosts";
-export default function ApiKeysPage() {
+// Vision API keys are a Donkey product surface; on donkeycut.com the settings
+// pages carry only the Cut-relevant tabs (see SettingsShell), and a deep link
+// here lands on the overview instead.
+export default async function ApiKeysPage() {
+ if (isDonkeycutHost((await headers()).get("host"))) redirect("/app/settings");
return <ApiKeysManager />;
}