Network & Monitoring
Response Headers
Inspect HTTP response headers for any URL from Cloudflare's edge - security, cache, and CORS header debugging
Fetch any URL and return its HTTP status and response headers as JSON.
API Reference
GET /headers
Uses HEAD first and falls back to GET when the origin does not support HEAD.
Prop
Type
Example Request
curl "https://your-worker.workers.dev/headers?url=https://www.cloudflare.com"Success Response
url string
Final URL after redirects
statusCode number
HTTP status code
statusText string
HTTP status text
method string
HEAD or GET
headers object
Response headers as key/value pairs
{
"url": "https://www.cloudflare.com/",
"statusCode": 200,
"statusText": "OK",
"method": "HEAD",
"headers": {
"content-type": "text/html; charset=utf-8",
"server": "cloudflare"
}
}Error Codes
400- Missing or invalidurl(INVALID_URL)502- Fetch failed (FETCH_ERROR)
Use Cases
- Debug cache and security headers from the edge
- Compare response headers across origins
- Learn HEAD vs GET fallback patterns in Workers
Limitations
- Uses HEAD with GET fallback; some origins return different headers per method
- Single URL per request
- Fetch timeout on slow origins
Use in your project
Copy these files into an existing Worker. Prefer Deployment to try the full experiment first. Source: apps/experiments/response-headers.
DependenciesNoneBindingsNonePlatformFetch API
import { USER_AGENT } from "../constants/defaults";import type { HeadersResponse } from "../types/headers";import { headersToRecord, shouldRetryWithGet } from "./url";async function fetchWithMethod(url: string, method: "HEAD" | "GET"): Promise<Response> { return fetch(url, { method, redirect: "follow", headers: { "User-Agent": USER_AGENT }, });}export async function inspectResponseHeaders(url: string): Promise<HeadersResponse> { let method: "HEAD" | "GET" = "HEAD"; let response = await fetchWithMethod(url, method); if (shouldRetryWithGet(response.status)) { method = "GET"; response = await fetchWithMethod(url, method); } return { url: response.url, statusCode: response.status, statusText: response.statusText, method, headers: headersToRecord(response.headers), };}Deployment
Test your deployment
curl "https://your-worker.workers.dev/headers?url=https://www.cloudflare.com"Local Development
cd apps/experiments/response-headers
npm install
npm run dev