Commit Graph
21 Commits
Author SHA1 Message Date
MythEclipse 6b9dd3770e refactor: extract test page to shared module, use env var for API key 2026-06-24 18:18:49 +07:00
MythEclipse d5f8dfc1d7 fix: auto-detect base URL from window.location.origin
- public/test-api.html: value di baseUrl input kosong, apiBase() fallback ke window.location.origin,
  plus DOMContentLoaded listener utk auto-fill
- api/test-api-content.ts: sama (legacy Next.js route)
- Router.ts handleDocs() sudah pakai pendekatan ini sebelumnya
2026-06-20 21:49:37 +07:00
MythEclipse cb6191902e fix: critical bugs, serverless stability, and security hardening
Bug Fixes:
- Fix rate limiter API mismatch: check() -> checkAsync() in index.ts, worker.ts, api/relay.ts
- Fix WebSocket SSRF silent drop: return error Response instead of undefined
- Fix isDevMode() default: changed from true to false (production-safe)
- Fix process.env -> env bindings in worker.ts requireAuth for Cloudflare Workers
- Fix Bun.file() crash in Workers: add try/catch with fallback
- Fix Bun.CryptoHasher -> Web Crypto API in mimo-auth.ts for Workers compat

Architecture:
- Add public methods to ProxyPool (getEntryAtIndex, getProxyUrlAtIndex, getCurrentIndex, setCurrentIndex) to remove all 'as any' casts in SessionProxyPool
- Add addProxy() method for manual proxy management
- Add loadAsync(), tryLoadAsync(), loadFromString() to ProxyPool

Serverless Stability:
- Add optional DNS rebinding protection via SSRF_DNS_CHECK env flag
- CORS cache now auto-invalidates when CORS_ORIGIN env changes
- Rate limiter max-size eviction (10k keys) prevents unbounded memory growth

Tests:
- Fix type assertions in test files (body as Record<string, unknown>)
- All 153 tests pass, typecheck clean
2026-06-19 18:10:49 +07:00
MythEclipseandClaude 778180a5dc fix: inline test-api.html as TypeScript string export for Vercel
Bun import of .html files returns HTMLBundle (not a string) in Vercel's
serverless environment, and Bun.file() has no filesystem access there.
Copy the HTML content into api/test-api-content.ts as an escaped string
export, then import it in api/relay.ts — Bun bundler inlines it.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 14:14:13 +07:00
MythEclipseandClaude f8fd18612b fix: use Bun.file().text() at module scope to inline test-api.html
Bun HTML import returns HTMLBundle object on Vercel serverless, which
renders as '[object HTMLBundle]'. Using Bun.file().text() at top-level
module scope ensures Bun bundler inlines the raw string at build time.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 13:54:13 +07:00
MythEclipseandClaude bcba2c5386 fix: use text import for test-api.html in Vercel deployment
Bun HTML import returns HTMLBundle object, not a string — Vercel
renders it as '[object HTMLBundle]'. Use 'with { type: "text" }'
to import as raw string so it renders properly.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 13:51:04 +07:00
MythEclipseandClaude bc6edbef3e fix: serve test-api.html at /docs on Vercel and Worker deployments
Update api/relay.ts (Vercel entry point) and src/worker.ts (Cloudflare
Workers entry point) to serve the interactive API test console at /docs
and /test, replacing the old inline docs page.

api/relay.ts uses Bun's HTML import (bundled inline at build time)
since filesystem access is unavailable in Vercel serverless runtime.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 13:37:23 +07:00
MythEclipseandClaude Fable 5 47b85fb396 chore: use hardcoded dummy API key
- Replace env-based API_KEY with sk-dummy-key hardcoded
- All entry points use same key: Authorization: Bearer sk-dummy-key
- Simplifies usage for library/client consumption

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 00:59:01 +07:00
MythEclipseandClaude Fable 5 c0a02279bd feat: add API key authentication for AI proxy endpoints
- Add API_KEY config (env var) to all entry points
- requireAuth helper checks Authorization: Bearer or x-api-key header
- Auth applied to /v1/chat/completions, /v1/messages, /v1/models
- When API_KEY is empty/unset, auth is disabled (backward compatible)
- Update wrangler.toml with API_KEY variable documentation

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 00:56:18 +07:00
MythEclipseandClaude Fable 5 2fead57d0f fix: use MODEL_ROUTES directly for Anthropic proxy routing
Remove the ANTHROPIC_MODEL_MAP layer — /v1/messages now uses the
same model names as /v1/chat/completions (deepseek-v4-flash-free,
gpt-5.4-mini-no-login, deepseek/deepseek-v4-flash). This way users
send the original model name and it routes to the correct backend.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 00:42:21 +07:00
MythEclipseandClaude Fable 5 38d7a83fe9 feat: add AI proxy routes to Workers and Vercel entry points
- Add /v1/chat/completions, /v1/messages, /v1/models routes to
  src/worker.ts (Cloudflare Workers) and api/relay.ts (Vercel)
- Import handleChatCompletion, handleAnthropicMessages handlers
- Using the same backend routing as the standalone server

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 23:45:38 +07:00
MythEclipseandClaude Fable 5 3f96d8a6e7 fix: relay requests to / with x-relay-target instead of showing index
When a GET request hits / with an x-relay-target header, it should relay
the request — not display the index page. Fixed in all three entry points
(src/index.ts, api/relay.ts, src/worker.ts).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 21:59:25 +07:00
MythEclipseandClaude Fable 5 9dc32e8b10 fix: correct Vercel Bun runtime config and handler export format
Per Vercel docs (vercel.com/docs/functions/runtimes/bun):
- Use top-level "bunVersion": "1.x" in vercel.json (NOT functions block)
- Export default { async fetch(request) { ... } } — object with fetch method
  (not a bare default function)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 21:20:16 +07:00
MythEclipseandClaude Fable 5 591c1fa199 fix: add Vercel-compatible relay handler and fix vercel.json runtime
- Create api/relay.ts: Vercel serverless function handler that reuses
  relay logic from src/lib/relay-utils.ts and src/middleware/
- Export default fetch handler (no Bun.serve()) for Vercel Functions
- Fix vercel.json: use @vercel/node@5 runtime with proper routing via
  rewrites to catch all traffic to the relay handler
- Remove stale buildCommand/outputDirectory (Vercel handles function builds)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 21:17:21 +07:00
MythEclipse b0dde3c885 refactor: migrate to Next.js with edge functions and update relay utilities
- Removed old relay utilities and tests, replacing them with a new structure under `src/lib/relay-utils.ts`.
- Implemented a new edge function in `app/api/proxy/route.ts` to handle proxy requests.
- Created a new Next.js layout and page structure for the frontend, including a user interface for testing the proxy.
- Added Tailwind CSS for styling and configured PostCSS.
- Updated TypeScript configuration for better compatibility with Next.js.
- Removed unused files and configurations related to the previous setup.
2026-05-07 20:59:23 +07:00
MythEclipse db175e6e95 fix: update fetch options to include target URL in buildRelayRequest 2026-05-07 20:43:09 +07:00
MythEclipse 9e2f4d39b1 feat: implement API handler for edge runtime with method validation and target normalization 2026-05-07 20:35:18 +07:00
MythEclipse a6333750e4 feat: update project structure and enhance UI for Edge Proxy Test
- Add .gitignore to exclude api directory
- Remove deprecated api/index.ts file
- Create new public/index.html with improved UI and functionality
- Update package.json build script to copy index.html to dist
- Enhance request handling in index.html with custom headers and presets
- Improve response display with status, time, and size metrics
2026-05-07 20:26:51 +07:00
MythEclipse 6f28d18b95 feat: refactor header handling and update module path in package.json 2026-05-07 19:55:39 +07:00
MythEclipse 8e0cf9d0f3 fix: update import path for relay-utils and restore functions configuration in vercel.json 2026-05-07 19:53:20 +07:00
MythEclipse 212ce32480 feat: implement Edge Proxy Relay with request handling and header filtering 2026-05-07 19:49:52 +07:00