# Universal CORS Proxy > Proxy HTTP requests and execute database queries from browsers via Cloudflare Workers. **Status: ok** ## Capabilities - HTTP/HTTPS proxy with full CORS support - Direct MySQL/MariaDB query execution - Direct PostgreSQL query execution - Dynamic social/Open Graph preview pages with PNG and SVG image routes - Native Cloudflare TCP sockets (no external dependencies) ## Endpoints ### GET / Health check and documentation (this page). ### GET /?url={target_url} ### GET /?u={target_url} ### GET /{target_url} Proxy any HTTP request with CORS headers. All methods supported (GET, POST, PUT, DELETE, etc.). ### POST /db/query Execute SQL query on MySQL or PostgreSQL database. `connectionString` may be a literal DSN or a stored worker env reference like $DATABASE_URL or $INFOHUAXIN_DATABASE_URL or $HUATONG_DATABASE_URL or $IWAKY_DATABASE_URL or $TENDERLOOP_DATABASE_URL or $MAGICINTERVIEW_DATABASE_URL. Stored env references resolve from the worker KV env store. ### POST /db/test Test database connection without executing a query. ### POST /db/schema Export full schema with compact AI-ready text, markdown, and 3 sanitized sample rows per table. ### GET /github/repo-zip?repo={owner/name}&ref={branch} Download a repo zip through the worker. Public repos work without a token. Private repos can use the worker's server-side `GITHUB_TOKEN` or a per-request `X-GitHub-Token` header. ### GET /dynamicrender?title={title}&description={description}&image={url} Create a shareable HTML page whose visible image matches its Open Graph and Twitter Card image. Use `svg` for encoded SVG markup, `/dynamicrender/image.png` for the raster social image, `/dynamicrender/image.svg` for vector output, and `/dynamicrender/meta.json` to inspect resolved metadata. Built-in templates (pick and preview them in the Render tab of `/ui`): - `card=fries&text=要洗澡!&seconds=600&total=600`: task countdown with a fries carton, progress bar and CJK text (`label` overrides the top line) - `card=deal&seconds=…&total=…&price=230&off=15&until=01:00&style=1..4`: booking-offer countdown - `card=listing&title=…&tag=…`: 1200×630 Chinese-title link card - `code=817146&lang=es`: verification voucher card - `seconds=…`: plain clock Change `v` on every edit so WhatsApp and caches fetch a fresh image. A WhatsApp message can show a live countdown by editing the same message with a new link each second (GOWA `/message/{id}/update` with `link`); WhatsApp accepts edits for ~15 minutes after sending. ## URL Proxy Usage ```bash # Query parameter format curl "https://cors.trigox.workers.dev/?url=https://api.example.com/data" # Short parameter format curl "https://cors.trigox.workers.dev/?u=https://api.example.com/data" # Path format curl "https://cors.trigox.workers.dev/https://api.example.com/data" # POST with body curl -X POST "https://cors.trigox.workers.dev/?url=https://api.example.com/submit" \ -H "Content-Type: application/json" \ -d '{"key": "value"}' ``` ## Database Query Usage ### Request Format (POST /db/query) ```json { "connectionString": "mysql://user:password@host:port/database", "query": "SELECT * FROM users WHERE id = ?", "params": [1] } ``` ### Connection String Formats | Database | Format | Default Port | |------------|------------------------------------------------|--------------| | MySQL | mysql://user:pass@host:3306/database | 3306 | | MariaDB | mariadb://user:pass@host:3306/database | 3306 | | PostgreSQL | postgres://user:pass@host:5432/database | 5432 | | PostgreSQL | postgresql://user:pass@host:5432/database | 5432 | ### Response Format ```json { "success": true, "database": "mysql", "rows": [{"id": 1, "name": "John"}], "fields": [{"name": "id"}, {"name": "name"}], "rowCount": 1 } ``` ### Error Response ```json { "success": false, "error": "MySQL Error 1045: Access denied for user", "code": "ER_ACCESS_DENIED_ERROR" } ``` ## Examples ### MySQL Query ```bash curl -X POST "https://cors.trigox.workers.dev/db/query" \ -H "Content-Type: application/json" \ -d '{ "connectionString": "mysql://root:password@db.example.com:3306/myapp", "query": "SELECT id, name, email FROM users LIMIT 10" }' ``` ### PostgreSQL Query ```bash curl -X POST "https://cors.trigox.workers.dev/db/query" \ -H "Content-Type: application/json" \ -d '{ "connectionString": "postgres://postgres:password@db.example.com:5432/myapp", "query": "SELECT * FROM products WHERE price > $1", "params": [100] }' ``` ### Query Using Stored Worker Env ```bash curl -X POST "https://cors.trigox.workers.dev/db/query" \ -H "Content-Type: application/json" \ -d '{ "connectionString": "$DATABASE_URL", "query": "SELECT 1" }' ``` ### Test Connection ```bash curl -X POST "https://cors.trigox.workers.dev/db/test" \ -H "Content-Type: application/json" \ -d '{ "connectionString": "mysql://root:password@db.example.com:3306/myapp" }' ``` ### Schema Export For AI Handoffs ```bash curl -X POST "https://cors.trigox.workers.dev/db/schema" \ -H "Content-Type: application/json" \ -d '{ "connectionString": "$DATABASE_URL", "samplesPerTable": 3, "repoSlug": "samihalawa/2026-MANUS-oulang", "connectionRef": "$DATABASE_URL" }' ``` ## JavaScript/Fetch Example ```javascript // Database query from browser const response = await fetch('https://cors.trigox.workers.dev/db/query', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ connectionString: '$DATABASE_URL', query: 'SELECT * FROM users' }) }); const { rows } = await response.json(); ``` ## Technical Details - Runtime: Cloudflare Workers - Database Protocol: Native TCP sockets (cloudflare:sockets) - Authentication: mysql_native_password (MySQL), SCRAM-SHA-256/cleartext (PostgreSQL) - CORS: Full permissive headers for browser access - Timeout: 30 seconds per request ## Status ✅ Operational ## Source https://github.com/samihalawa/cloudflare-workers-cors-proxy