From 11d3972a744ec7de543f50938602e26e079396c8 Mon Sep 17 00:00:00 2001 From: Michelle Date: Wed, 4 Mar 2026 22:33:43 +0100 Subject: [PATCH] feat(caldav): implement service discovery for CalDAV with redirection --- server/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server/index.js b/server/index.js index c91b6de..9be08ef 100644 --- a/server/index.js +++ b/server/index.js @@ -79,6 +79,21 @@ async function start() { app.use('/api/federation', calendarRoutes); app.get('/.well-known/redlight', wellKnownHandler); + // ── CalDAV service discovery (RFC 6764) ────────────────────────────────── + // Clients probe /.well-known/caldav then PROPFIND / before they know the + // real CalDAV mount point. Redirect them to /caldav/ for all HTTP methods. + app.all('/.well-known/caldav', (req, res) => { + res.redirect(301, '/caldav/'); + }); + // Some clients (e.g. Thunderbird) send PROPFIND / directly at the server root. + // Express doesn't register non-standard methods, so intercept via middleware. + app.use('/', (req, res, next) => { + if (req.method === 'PROPFIND' && req.path === '/') { + return res.redirect(301, '/caldav/'); + } + next(); + }); + // Serve static files in production if (process.env.NODE_ENV === 'production') { app.use(express.static(path.join(__dirname, '..', 'dist')));