feat: add Cloudflare Worker implementation for edge-to-edge streaming bypass

- Add worker.js: full API on Cloudflare's edge network (1720 lines)
- Add wrangler.toml: deployment configuration for wrangler CLI
- Streaming endpoints now bypass Cloudflare bot detection via edge-to-edge
- Zero cold starts, 100K free requests/day, no npm dependencies
- 15 endpoints: search, trending, info, episodes, watch, genres, random, etc.
- Self-healing fallback: direct → ScraperAPI → FlareSolverr
- Proper code style: box headers, JSDoc, feature markers, inline notes
- Bump version to 2.3.2 across package.json, server.js, apiRoutes.js

Fixes #2
This commit is contained in:
Shinei Nouzen
2026-08-05 20:39:31 +05:30
parent d08bb86931
commit a2ba1df831
6 changed files with 1788 additions and 4 deletions
+42
View File
@@ -1,5 +1,47 @@
# Changelog
## v2.3.2
### Cloudflare Worker Implementation — Issue #2 Fix
#### New: `worker.js` (Cloudflare Worker Edge Runtime)
- **Full Cloudflare Worker implementation** created at project root
- Edge-to-edge requests bypass Cloudflare bot detection (Worker → miruro.to → Cloudflare trusts itself)
- Zero cold starts, 100K free requests/day on Cloudflare free tier
- No npm dependencies — uses native `fetch`, `DecompressionStream`, `TextEncoder`/`TextDecoder`
- 15 API endpoints: search, suggestions, filter, trending, trending/daily, trending/weekly, popular, top, upcoming, recent, random, info, episodes, watch, stream, genres, tags, providers, health
#### New: `wrangler.toml`
- Cloudflare Workers deployment configuration
- Compatible with `wrangler deploy` CLI
- Node.js compatibility flag enabled for buffer/text encoding support
- CPU time limit: 30 seconds
#### Architecture
```
Browser → Cloudflare Worker (edge) → miruro.to pipe → Cloudflare trusts itself ✅
Vercel (datacenter) → miruro.to → Cloudflare blocks ❌
```
#### Deploy
```bash
npm install -g wrangler
wrangler login
wrangler deploy worker.js --name miruroapi
```
#### Files Changed
- `worker.js` — Cloudflare Worker implementation (complete rewrite for edge runtime)
- `wrangler.toml` — Cloudflare Workers deployment configuration
- `CHANGELOG.md` — This entry
#### Notes
- This fixes Issue #2: Cloudflare Worker/Pages deployment support
- Streaming endpoints (`/episodes`, `/watch`, `/stream`) now work via edge-to-edge requests
- Environment variables `SCRAPER_API_KEY` and `FLARESOLVERR_URL` are optional for fallback methods
- The worker runs on Cloudflare's edge network with zero cold starts
---
## v2.3.1
### Cloudflare Worker Edition — Streaming Bypasses Cloudflare
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "miruro-api",
"version": "2.3.0",
"version": "2.3.2",
"description": "RESTful API for Miruro - Anime streaming data powered by AniList GraphQL and Miruro streaming providers",
"main": "server.js",
"scripts": {
+1 -1
View File
@@ -301,7 +301,7 @@ app.use((req, res) => {
if (!process.env.VERCEL) {
app.listen(PORT, () => {
console.log(`[${new Date().toISOString()}] MiruroAPI v2.3.0 listening at ${PORT}`);
console.log(`[${new Date().toISOString()}] MiruroAPI v2.3.2 listening at ${PORT}`);
});
}
+2 -2
View File
@@ -1124,7 +1124,7 @@ const createApiRoutes = (jsonResponse, jsonError, startTime) => {
success: true,
results: {
status: "healthy",
version: "2.3.0",
version: "2.3.2",
uptime: `${hours}h ${minutes}m ${seconds}s`,
uptimeSeconds: uptime,
timestamp: new Date().toISOString(),
@@ -1211,7 +1211,7 @@ const createApiRoutes = (jsonResponse, jsonError, startTime) => {
info: {
title: "MiruroAPI",
description: "Free REST API for anime streaming data — AniList GraphQL + Miruro streaming providers",
version: "2.3.0",
version: "2.3.2",
contact: { name: "Shineii86", url: "https://github.com/Shineii86/MiruroAPI" },
},
servers: [
+1720
View File
File diff suppressed because it is too large Load Diff
+22
View File
@@ -0,0 +1,22 @@
name = "miruroapi"
main = "worker.js"
compatibility_date = "2024-01-01"
# Cloudflare Worker configuration for MiruroAPI
# Deploy with: wrangler deploy
# Environment variables (set via wrangler secret put or dashboard)
# SCRAPER_API_KEY = "" # ScraperAPI premium key (optional, $49/mo)
# FLARESOLVERR_URL = "" # FlareSolverr Docker instance URL (optional)
# Route configuration (optional — for custom domains)
# routes = [
# { pattern = "api.your-domain.com/api/*", zone_name = "your-domain.com" }
# ]
# Limits
[limits]
cpu_ms = 30000
# Compatibility flags
compatibility_flags = ["nodejs_compat"]