- Execute fetch requests using JSON configuration
- Automatic handling of JSON request/response bodies
- CORS support built-in
- Detailed response information including headers and status
- Handles both JSON and non-JSON responses
- User-friendly error messages
- Interactive documentation when accessed via browser
Send a POST request to your worker's URL with a JSON payload containing your fetch configuration:
const response = await fetch('https://fetch-worker.your-subdomain.workers.dev/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://api.example.com/data',
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_TOKEN'
}
})
});
const result = await response.json();The worker returns a standardized JSON response:
{
"success": true,
"status": 200,
"statusText": "OK",
"headers": {
"content-type": "application/json",
// ... other headers
},
"data": {
// Response data from the target API
}
}If there's an error, you'll receive a response like:
{
"success": false,
"error": "Error message describing what went wrong"
}This project uses Bun as the JavaScript runtime.
- Bun installed on your system
- Cloudflare account with Workers access
- Wrangler CLI installed
- Clone the repository
- Install dependencies:
bun install
bun run dev- Start a local development serverbun run deploy- Deploy to Cloudflarebun run test- Run tests
The worker can be configured through wrangler.jsonc. See Cloudflare's documentation for more details.
MIT
