Prompt
How do I debug edge function requests not reaching my origin?
Latest observation
Here’s a practical checklist to debug edge function requests not reaching your origin.
1) Confirm the request actually hits the edge function
Add logging at the very start of the edge handler.
- Log method, URL, headers you care about, and a unique request ID.
- Return a temporary marker response if needed.
Example idea:
- “edge received request”
- request path
x-request-id
If you don’t see logs, the problem is before your function:
- route not matched
- deployment not active
- function disabled
- auth/WAF blocking
- wrong hostname or path
2) Verify routing and match patterns
Check:
- domain/hostname
- path pattern
- method restrictions
- function association order
Common issue:
- The edge function is attached to
/api/*, but the request goes to/apior/v1/api - A default route or rewrite sends traffic somewhere else
- A different edge rule is taking precedence
3) Check whether the function is short-circuiting
Your edge code may be:
- returning a response directly
- failing before proxying
- rewriting to an invalid origin path
- not forwarding the request body/headers correctly
Look for:
return new Response(...)- missing
fetch(originUrl, request)or equivalent - accidental early exit on conditionals
4) Inspect origin forwarding logic
If the edge function proxies to origin, confirm:
- origin URL is correct
- protocol is correct (
httpsvshttp) - hostname resolves
- path is preserved or intentionally rewritten
- query string is preserved
- headers required by origin are forwarded
Watch out for:
- using the wrong header set
- dropping
Host - altering
Authorization - not forwarding cookies if needed
- stripping
Content-Type - body already consumed before forwarding
5) Check for origin-side blocks
The request may arrive but be rejected by origin, so it looks like it never reached it.
Inspect origin logs and status codes:
403from origin/WAF404from origin routing502/504from upstream- TLS/SSL handshake failures
Also verify:
- IP allowlists
- firewall rules
- bot protection
- auth middleware
- rate limits
6) Add end-to-end identifiers
Use a request ID across edge and origin.
- At edge: generate or forward
x-request-id - At origin: log that same ID
This tells you exactly where the request stops.
7) Use curl to isolate layers
Test directly against:
- the public edge URL
- the origin URL
- the edge with special headers
Examples:
curl -v https://edge.example.com/pathcurl -v https://origin.example.internal/path
Compare:
- status codes
- redirects
- headers
- timing
8) Check response timing and failures
If the edge function times out, origin may never be contacted or the response never returns.
Look for:
- execution timeout
- upstream timeout
- DNS resolution errors
- TLS errors
- connection refused
Log around the fetch call:
- before fetch
- after fetch
- catch block error message
9) Confirm body handling
For POST/PUT/PATCH requests:
- Ensure the body is still readable when proxied
- Some runtimes allow the body to be read only once
- Clone the request if needed
If body handling is wrong, the origin may receive an empty body or the proxy may fail.
10) Review platform-specific edge limitations
Some edge environments limit:
- outbound network access
- certain ports
- request body size
- header size
- supported APIs
- custom TLS behavior
Check platform docs for:
- function runtime constraints
- proxy/fetch support
- origin connection requirements
11) Use temporary debug headers
Add headers from edge to origin:
x-edge-debug: truex-edge-routed-by: my-functionx-request-id: ...
Then inspect whether origin receives them.
12) If you have CDN/WAF, check their logs too
If your stack is: Client → CDN → Edge Function → Origin
then any of these could block the request:
- CDN cache rule
- WAF rule
- bot mitigation
- function invocation failure
- origin shield / upstream config
Quick triage flow
- No edge logs? Route/deployment issue.
- Edge logs but no origin logs? Proxy/origin connectivity issue.
- Origin logs but no expected response? Origin app/routing/auth issue.
- Works with direct origin curl but not through edge? Edge rewrite/headers/body issue.
If you want, I can also give you:
- a platform-specific checklist for Cloudflare / Fastly / AWS CloudFront / Vercel / Netlify
- a sample debug proxy edge function
- help interpreting specific logs or code if you paste them here