This site is not affiliated with or endorsed by Cloudflare, Inc. It showcases deployable experiments across most Cloudflare products.
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 invalid url (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

Click the deploy button

Deploy to Cloudflare Workers

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

Cloudflare Features Used

On this page