Skip to content

Instantly share code, notes, and snippets.

@abbaspour
Last active July 29, 2025 03:05
Show Gist options
  • Save abbaspour/4be371d350250ce23881a5bcfd9b45a2 to your computer and use it in GitHub Desktop.
Save abbaspour/4be371d350250ce23881a5bcfd9b45a2 to your computer and use it in GitHub Desktop.
Auth0 Custom Domain Cloudflare Worker
export default {
async fetch(request, env) {
request = new Request(request);
const url = new URL(request.url);
url.hostname = env.AUTH0_EDGE_RECORD;
request.headers.set('cname-api-key', env.CNAME_API_KEY);
const response = await fetch(url, request);
return response;
}
}
name = "auth0-custom-domain-fetch"
main = "worker.mjs"
compatibility_date = "2025-07-29"
workers_dev = false
routes = [
{ pattern = "my-auth0-self-managed-custom-domain.com", custom_domain = true }
]
[observability.logs]
enabled = true
[vars]
AUTH0_EDGE_RECORD = "xxx.auth0.com"
CNAME_API_KEY = "yyy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment