Files
mnote/wolai-frontend/src/app/api/workspaces/switch/route.ts
T
2026-01-18 19:01:31 +08:00

25 lines
843 B
TypeScript

import { NextResponse } from "next/server";
import { isConvexEnabled } from "@/lib/convex/enabled";
import { getAuthedConvexClient } from "@/lib/convex/route";
import { api } from "@/lib/convex/api";
export const dynamic = "force-dynamic";
export async function POST(request: Request) {
if (isConvexEnabled()) {
const { client } = await getAuthedConvexClient();
const payload = await request.json().catch(() => ({}));
const workspaceId = payload.workspaceId as string | undefined;
if (!workspaceId) {
return NextResponse.json({ error: "缺少 workspaceId" }, { status: 400 });
}
await client.mutation(api.workspaces.switchDefaultWorkspace, {
workspaceId,
});
return NextResponse.json({ success: true });
}
return NextResponse.json({ error: "仅支持 Convex 模式" }, { status: 501 });
}