Last active
September 11, 2025 21:45
-
-
Save jogerj/09723ba9f82d4194512244bd916c941f to your computer and use it in GitHub Desktop.
Cloudflare Worker for redirecting autodiscovery/autoconfiguration of email servers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Handle redirects with cloudflare worker to avoid duplication | |
| * https://forum.sympl.io/t/configure-auto-discover-for-mail-setup/94/6 | |
| */ | |
| export default { | |
| async fetch(request) { | |
| const url = new URL(request.url); | |
| if (url.pathname === "/.well-known/autoconfig/mail/config-v1.1.xml") { | |
| const targetUrl = `https://autoconfig.${url.hostname}/mail/config-v1.1.xml`; | |
| return fetch(targetUrl, request); | |
| } | |
| if (url.pathname === "/autodiscover/autodiscover.xml") { | |
| const targetUrl = `https://autodiscover.${url.hostname}/autodiscover/autodiscover.xml` | |
| return fetch(targetUrl, request) | |
| } | |
| return fetch(request); | |
| }, | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment