mirror of
https://github.com/Shineii86/MiruroAPI.git
synced 2026-10-22 10:15:10 +00:00
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:
@@ -1,5 +1,47 @@
|
|||||||
# Changelog
|
# 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
|
## v2.3.1
|
||||||
### Cloudflare Worker Edition — Streaming Bypasses Cloudflare
|
### Cloudflare Worker Edition — Streaming Bypasses Cloudflare
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "miruro-api",
|
"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",
|
"description": "RESTful API for Miruro - Anime streaming data powered by AniList GraphQL and Miruro streaming providers",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ app.use((req, res) => {
|
|||||||
|
|
||||||
if (!process.env.VERCEL) {
|
if (!process.env.VERCEL) {
|
||||||
app.listen(PORT, () => {
|
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}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1124,7 +1124,7 @@ const createApiRoutes = (jsonResponse, jsonError, startTime) => {
|
|||||||
success: true,
|
success: true,
|
||||||
results: {
|
results: {
|
||||||
status: "healthy",
|
status: "healthy",
|
||||||
version: "2.3.0",
|
version: "2.3.2",
|
||||||
uptime: `${hours}h ${minutes}m ${seconds}s`,
|
uptime: `${hours}h ${minutes}m ${seconds}s`,
|
||||||
uptimeSeconds: uptime,
|
uptimeSeconds: uptime,
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
@@ -1211,7 +1211,7 @@ const createApiRoutes = (jsonResponse, jsonError, startTime) => {
|
|||||||
info: {
|
info: {
|
||||||
title: "MiruroAPI",
|
title: "MiruroAPI",
|
||||||
description: "Free REST API for anime streaming data — AniList GraphQL + Miruro streaming providers",
|
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" },
|
contact: { name: "Shineii86", url: "https://github.com/Shineii86/MiruroAPI" },
|
||||||
},
|
},
|
||||||
servers: [
|
servers: [
|
||||||
|
|||||||
@@ -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"]
|
||||||
Reference in New Issue
Block a user