f6226facbd
Harden the BYO-mode signal at the API boundary (start/scene/insert-beat): only clientTts === true drops server TTS, so a stray truthy non-boolean can't silently disable it. Add a non-blocking prefix hint in TtsKeyModal that warns when the pasted key prefix (tp-/sk-) mismatches the selected key type — a mismatch hits the wrong endpoint and plays silently, the symptom BYO fixes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { requestInsertBeat } from "@infiplot/engine";
|
|
import type { InsertBeatRequest } from "@infiplot/types";
|
|
import { NextResponse } from "next/server";
|
|
import { loadEngineConfig } from "@/lib/config";
|
|
|
|
export const runtime = "nodejs";
|
|
export const maxDuration = 60;
|
|
|
|
export async function POST(req: Request) {
|
|
let body: InsertBeatRequest;
|
|
try {
|
|
body = (await req.json()) as InsertBeatRequest;
|
|
} catch {
|
|
return NextResponse.json({ error: "Invalid JSON" }, { status: 400 });
|
|
}
|
|
|
|
if (!body.session || !body.freeformAction) {
|
|
return NextResponse.json(
|
|
{ error: "session and freeformAction are required" },
|
|
{ status: 400 },
|
|
);
|
|
}
|
|
|
|
try {
|
|
const base = loadEngineConfig(req.headers);
|
|
// See StartRequest.clientTts — BYO clients synth in-browser, so drop server TTS.
|
|
const config = body.clientTts === true ? { ...base, tts: undefined } : base;
|
|
const result = await requestInsertBeat(config, body);
|
|
return NextResponse.json(result);
|
|
} catch (err) {
|
|
const message = err instanceof Error ? err.message : "Unknown error";
|
|
return NextResponse.json({ error: message }, { status: 500 });
|
|
}
|
|
}
|