Cannot open index.html with mailto: or discord: redirect. Why?
I have a Cloudflare Worker that acts as a reverse proxy to my site hosted on Netlify. Everything works perfectly when I use the Worker’s own URL (mirror.example-worker.workers.dev) — all links, including mailto: and discord: redirects, work fine.
However, when I connect my custom domain (example.dev) to the same Worker via Cloudflare DNS, some links start behaving incorrectly:
Links like /ds or /discord, which are supposed to trigger a
discord:
redirect URI, unexpectedly redirect to the default landing page (which should only appear for clean URLs like example.dev without /discord or /ds). This behavior only happens when accessing the site via my custom domain through Cloudflare — using the direct Worker URL works fine
.
Similarly, mailto:
links sometimes do nothing or behave incorrectly, instead of opening the email client as expected.
The issue seems unrelated to my Netlify mirror itself. This problem only appears when visiting through my custom domain.
If I make a direct GET request via Cloudflare Editor or Postman to https://example.dev/ds, it works correctly and opens Discord.
It looks like there’s a difference in how requests are handled when going through my domain vs. the Worker subdomain. Possible causes I’m considering:
Cloudflare “Proxied” DNS mode interfering
Certain headers being modified or stripped by the Cloudflare proxy
Browser security rules for custom schemes (discord:, mailto:) when accessed via a proxied domain
Question:
How can I make my custom domain behave exactly the same as the Worker URL for these redirects?1 Reply
worker.js code for reverse proxy:
index.html for mailto: redirect
index.html for discord: redirect