返回资讯列表

我是如何在0美元基础设施上 搭建一个全自动的动画流线平台 共2 733集

2026年9月9日8 次浏览来源:Dev.to阅读原文

正文保留英文原文(机翻易破坏代码与排版),标题/摘要已提供中文

The Challenge

I wanted to prove that a complete streaming platform could be built with zero monetary investment. No AWS credits. No paid hosting. Just free tiers, automation, and a lot of JavaScript.

The result: 161+ anime titles, 2,733 episodes, 15 languages, and a full admin panel – all running on $0/month infrastructure.

The Stack

Layer Technology Frontend Next.js 14, React, TypeScript, Tailwind CSS Backend API Cloudflare Workers (serverless) Database Cloudflare D1 (SQLite) + Supabase (PostgreSQL) Cache Cloudflare KV (< 50ms response time) Auth Supabase Auth Notifications Firebase FCM Video Player HLS.js with custom CORS-proxy bypass Hosting Vercel (frontend) + Cloudflare Workers (API)

Infrastructure cost: $0/month. Yes, really.

The Hard Parts

1. HLS Streaming with CORS Bypass

Video streams (M3U8 playlists) from third-party sources often block cross-origin requests. I built a custom proxy route that:

  • Fetches the M3U8 playlist
  • Rewrites all segment URLs to go through the proxy
  • Streams back the modified playlist to the client
  • Handles CORS headers properly

The proxy handles both .m3u8 playlists and binary segments (.ts, .m4s) while preserving Range headers for partial content.

Code snippet – proxy playlist rewriting:


javascript
const rewritten = text
  .split(/\r?\n/)
  .map(line => {
    const trimmed = line.trim();
    if (!trimmed || trimmed.startsWith('#') || trimmed.includes('/api/proxy')) {
      return line;
    }
    try {
      const resolved = new URL(trimmed, baseUrl).toString();
      return `/api/proxy?url=${encodeURIComponent(resolved)}`;
    } catch {
      return line;
    }
  })
  .join('\n');
分享