TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/betterspacx/app/llms.txt
Use this file to discover all available pages before exploring further.
/api/upload-video route is the direct upload path for the Betterflow Chrome extension. When the extension finishes recording a screen capture, it base64-encodes the video Blob and POSTs it to this endpoint. The server decodes the data, constructs an R2 object key under backgrounds/videos/, and uploads the binary to your R2 bucket using the Cloudflare REST API — returning a public CDN URL the editor can load immediately.
This route complements /api/upload-url: use /upload-url when the client can PUT directly to R2; use /upload-video when the extension must route through the server (e.g. due to strict CSP rules or firewall constraints).
Endpoint
| Property | Value |
|---|---|
| Method | POST |
| Path | /api/upload-video |
| Content-Type | application/json |
OPTIONS) are handled automatically, allowing the Chrome extension to call this route from any origin.
Request Body
The complete video file encoded as a Base64 string. The server decodes this with
Buffer.from(videoBase64, 'base64') before uploading to R2. Only video/webm content is expected from the Chrome extension.The desired filename for the uploaded video. If omitted, the server generates a timestamp-based name:
recording-{Date.now()}.webm. The final R2 key is always prefixed with backgrounds/videos/{timestamp}-.Response Body
A successful200 response returns:
true when the upload to R2 completed without errors.The public URL of the uploaded video, served via
NEXT_PUBLIC_CDN_URL. The editor uses this URL to load the video as a background asset directly on the Konva canvas.Example
Because the entire video payload is serialized as JSON, this route is best suited for short recordings. For longer videos, prefer the presigned-URL flow via
/api/upload-url, which streams the file directly from the browser to R2 without sending it through the Next.js server.Error Responses
| Status | Description |
|---|---|
400 Bad Request | videoBase64 is missing from the request body. Returns { "error": "Missing video data" }. |
500 Internal Server Error | The Cloudflare R2 API returned a non-OK status, or the server environment variables (CLOUDFLARE_ACCOUNT_ID, R2_BUCKET_NAME, R2_API_TOKEN) are not configured. Returns { "error": "Upload failed", "details": "<error message>" }. |