Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/web/app/api/tools/loom-download/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { randomUUID } from "node:crypto";
import { getCurrentUser } from "@cap/database/auth/session";
import { type NextRequest, NextResponse } from "next/server";
import {
fetchConvertedVideoViaMediaServer,
Expand Down Expand Up @@ -160,6 +161,11 @@ async function tryMp4CandidateDownload(
}

export async function GET(request: NextRequest) {
const user = await getCurrentUser();
if (!user) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
Comment on lines +164 to +167
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 No per-user rate limiting

An authenticated user can still hammer this endpoint to exhaust server bandwidth (video streaming) and CPU (ffmpeg conversion). The auth gate prevents anonymous abuse but doesn't cap usage per account. Consider adding a rate limit middleware (e.g. a simple in-memory counter or an existing rate-limiter if the codebase has one) on this route to bound the blast radius of a compromised or misbehaving account.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/app/api/tools/loom-download/route.ts
Line: 164-167

Comment:
**No per-user rate limiting**

An authenticated user can still hammer this endpoint to exhaust server bandwidth (video streaming) and CPU (ffmpeg conversion). The auth gate prevents anonymous abuse but doesn't cap usage per account. Consider adding a rate limit middleware (e.g. a simple in-memory counter or an existing rate-limiter if the codebase has one) on this route to bound the blast radius of a compromised or misbehaving account.

How can I resolve this? If you propose a fix, please make it concise.


const videoId = request.nextUrl.searchParams.get("id");
const videoName = request.nextUrl.searchParams.get("name");

Expand Down
Loading