Skip to content

Open source CapCut alternative.

TypeScript

fix(site): move Cut host routing from root middleware.ts to src/proxy.ts

David Lee46b3fddbfa1
diff --git a/docs/guides/cut.md b/docs/guides/cut.md
index 8d0af7db..51faf1d2 100644
--- a/docs/guides/cut.md
+++ b/docs/guides/cut.md
@@ -52,4 +52,4 @@ Because storage is local disk and AI rides the serving machine's CLI logins, Cut
## Where it lives
-The editor and its server code sit under the site app's Cut folder; its pages and API handlers mount under the shared route tree, and host-based routing lives in the site's middleware.
+The editor and its server code sit under the site app's Cut folder; its pages and API handlers mount under the shared route tree, and host-based routing lives in the site's proxy file (`src/proxy.ts`, the Next 16 successor to middleware).
diff --git a/site/middleware.ts b/site/src/proxy.ts
similarity index 86%
rename from site/middleware.ts
rename to site/src/proxy.ts
index ea72783b..18cb9065 100644
--- a/site/middleware.ts
+++ b/site/src/proxy.ts
@@ -7,11 +7,14 @@ import { NextResponse, type NextRequest } from "next/server";
// /api/* and Next internals are left untouched — Cut's API handlers are mounted
// under the shared /api tree and don't collide with Donkey's.
//
+// This file must live in src/ (next to app/) and use the Next 16 `proxy` name;
+// a root-level middleware.ts is not loaded when the app is under src/.
+//
// Local dev: add nothing to /etc/hosts — `cut.localhost` already resolves to
// 127.0.0.1, so http://cut.localhost:3000/ exercises this path.
const CUT_HOSTS = new Set(["cut.donkeyuse.com", "cut.localhost"]);
-export function middleware(req: NextRequest) {
+export function proxy(req: NextRequest) {
const host = (req.headers.get("host") ?? "").split(":")[0];
if (!CUT_HOSTS.has(host)) return NextResponse.next();