# YouTube Transcripts on Vercel, Netlify, and Cloudflare Workers

Source: https://transcript-yt.com/blog/youtube-transcript-vercel-serverless · Updated 2026-11-10 · TranscriptYT

> YouTube transcript libraries work in next dev and fail on Vercel, Netlify, and Cloudflare Workers, because YouTube blocks serverless IPs. Fetch transcripts through an API route that calls a transcript API instead.

The YouTube transcript feature works in next dev and returns errors in production: an empty transcript, "Transcript is disabled", a 429, or RequestBlocked if it's a Python function. Vercel and Netlify functions run on AWS, and Cloudflare Workers on Cloudflare's network; YouTube distrusts all of these IPs for caption requests, so the same scraping code that works on your laptop fails once deployed.

## Next.js route handler

Put the key in the project's environment variables (TRANSCRIPTYT_KEY) and proxy requests through a route handler. The [TranscriptYT API](https://transcript-yt.com/api) does the YouTube side, so nothing on Vercel talks to YouTube.

```
// app/api/transcript/route.ts
export async function GET(request: Request) {
  const url = new URL(request.url).searchParams.get("url");
  if (!url) return Response.json({ error: "url is required" }, { status: 400 });
  const res = await fetch(
    `https://transcript-yt.com/v1/transcript?url=${encodeURIComponent(url)}`,
    { headers: { Authorization: `Bearer ${process.env.TRANSCRIPTYT_KEY}` } },
  );
  return Response.json(await res.json(), { status: res.status });
}
```

## Cloudflare Worker

```
export default {
  async fetch(request, env) {
    const url = new URL(request.url).searchParams.get("url");
    return fetch(
      `https://transcript-yt.com/v1/transcript?url=${encodeURIComponent(url)}&format=text`,
      { headers: { Authorization: `Bearer ${env.TRANSCRIPTYT_KEY}` } },
    );
  },
};
```

## Timeouts and long videos

Captioned videos return in a second or two. A video with no captions is transcribed with AI, which takes about a minute or two for an hour of audio, so raise the function's max duration (maxDuration in Next.js) or pass mode=captions to fail fast instead of transcribing.

## Building an AI feature?

Ask for format=text or format=md to send the transcript straight to a model, or call /v1/summary for a ready-made summary. For agents, the [MCP server](https://transcript-yt.com/mcp-guide) gives the model the transcript as a tool.

## FAQ

### Why does my YouTube transcript code work locally but not on Vercel?

Locally the request comes from your residential IP. On Vercel it comes from a cloud IP, which YouTube blocks or serves without captions. The code is fine; the network isn't.

### Does it fail on Netlify and Cloudflare Workers too?

Yes. Netlify functions run on AWS and Workers on Cloudflare's IPs, and YouTube treats both as datacenter traffic.

### Can I fetch YouTube transcripts in the browser instead?

Not directly: YouTube's caption endpoints don't allow cross-origin requests, so client-side fetches are blocked by CORS. Call your own API route, which calls a transcript API.

### How do I keep my API key out of the browser?

Keep it in an environment variable and call the transcript API from a route handler or server action, never from client components.
