From 507cb77e85ad6508c4d17205610cb779fc29cf5d Mon Sep 17 00:00:00 2001 From: Lennart <18233294+lennart-k@users.noreply.github.com> Date: Sun, 20 Jul 2025 13:10:52 +0200 Subject: [PATCH] Add /.well-known/caldav exception for Apple Calendar --- src/app.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index 4fd1c9b..4864671 100644 --- a/src/app.rs +++ b/src/app.rs @@ -4,6 +4,7 @@ use axum::body::Body; use axum::extract::Request; use axum::response::{Redirect, Response}; use axum::routing::{any, options}; +use axum_extra::TypedHeader; use headers::{HeaderMapExt, UserAgent}; use http::{HeaderValue, StatusCode}; use rustical_caldav::caldav_router; @@ -58,7 +59,17 @@ pub fn make_app( )) .route( "/.well-known/caldav", - any(async || Redirect::permanent("/caldav")), + any(async |TypedHeader(ua): TypedHeader| { + if ua.as_str().contains("remindd") { + // remindd is an Apple Calendar User Agent + // Even when explicitly configuring a principal URL in Apple Calendar Apple + // will not respect that configuration but call /.well-known/caldav, + // so sadly we have to do this user-agent filtering. :( + // (I should have never gotten an Apple device) + return Redirect::permanent("/caldav-compat"); + } + Redirect::permanent("/caldav") + }), ) .merge(carddav_router( "/carddav",