Prompt
I need edge functions that can inspect headers and cookies
Latest observation
Oct 26, 2026
OpenAI APIWeb search: off
Yes — edge functions can inspect both request headers and cookies.
What they can access
In most edge runtimes, you can read:
- Headers from the incoming request
- Cookies from the request headers, usually via the
Cookieheader - Sometimes also set response headers/cookies
Example logic
If you're using a fetch-style edge function:
export default {
async fetch(request) {
const headers = request.headers;
const cookieHeader = headers.get("cookie") || "";
return new Response(JSON.stringify({
userAgent: headers.get("user-agent"),
cookies: cookieHeader
}), {
headers: { "content-type": "application/json" }
});
}
};
If you want parsed cookies
You can manually parse the Cookie header:
function parseCookies(cookieHeader) {
return Object.fromEntries(
cookieHeader.split(";").map(cookie => {
const [name, ...rest] = cookie.trim().split("=");
return [name, rest.join("=")];
}).filter(([name]) => name)
);
}
Things to keep in mind
- Cookie availability depends on the request actually including them
HttpOnlycookies are still visible to the server/edge functionSecurecookies only arrive over HTTPS- Cross-site requests may omit cookies depending on
SameSite
If you tell me which platform you mean by “edge functions” — for example Cloudflare Workers, Vercel Edge Functions, Netlify Edge, or Supabase Edge Functions — I can give you the exact code for that environment.