For the complete documentation index, see llms.txt. This page is also available as Markdown.

Post-Process Hooks After Auth0 Callback

Run post-processing only when the Auth0 callback needs extra side effects after token exchange succeeds. The Auth0 callback integration supports a post-process

Run post-processing only when the Auth0 callback needs extra side effects after token exchange succeeds. The Auth0 callback integration supports a post-process hook that runs after the authorization code is exchanged for tokens. Use this to store tokens, create sessions, or enrich the callback response.

Last reviewed: 2026-03-06

When to use this

Use the service execution recipes when your routes need to call Worker code directly instead of proxying to an external HTTP endpoint. The gateway supports two patterns: local service modules bundled with the worker, and service bindings that call separately deployed Workers via Cloudflare bindings.

Key concepts

  • The service integration type imports a local JavaScript module from the worker project and calls its default export. The module ships in the same worker bundle.

  • The service_binding integration type calls a separately deployed Worker through a Cloudflare service binding. The target Worker must be deployed independently and bound in wrangler.toml.

  • Pre-process hooks run before the main integration and can short-circuit the request by returning a response. Use them for custom authorization, input validation, or request enrichment.

  • Post-process hooks run after the main integration returns and can modify the response. The Auth0 callback post-process hook is the most common use case.

  • When choosing between proxy and service execution, consider latency (service bindings avoid an external HTTP round-trip) and coupling (proxy keeps the backend independently deployable).

Repo-grounded example

{
  "authorizer": {
    "type": "auth0",
    "domain": "$env.AUTH0_DOMAIN",
    "client_id": "$env.AUTH0_CLIENT_ID",
    "client_secret": "$secrets.AUTH0_CLIENT_SECRET",
    "redirect_uri": "https://api.example.com/api/v1/auth0/callback",
    "callback_uri": "https://app.example.com/auth/callback",
    "jwks_uri": "https://tenant.us.auth0.com/.well-known/jwks.json",
    "scope": "openid profile email"
  },
  "paths": [
    {
      "method": "GET",
      "path": "/api/v1/auth0/callback",
      "integration": { "type": "auth0_callback" }
    }
  ]
}

This snippet shows the Auth0 authorizer and callback route. To add a post-process hook, include a post_process field on the callback path entry with a binding and function that reference a service binding Worker. The hook receives the token exchange response.

Troubleshooting

  • If a service integration returns 500, confirm that the entrypoint path in the services array matches the actual file location relative to the worker root and that the module exports a default function.

  • If a service_binding integration returns a binding error, verify that the binding name in config matches the binding declared in wrangler.toml and that the target Worker is deployed.

  • If a pre-process hook does not short-circuit as expected, check that the hook function returns a Response object -- returning undefined or null lets the request continue to the main integration.

  • If post-process hooks are not running, confirm the hook config uses the correct binding and function field names and that the hook Worker is deployed and bound.

Last updated