From 4eb05d96adcee19929b1c741d9a4506824fa661f Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Tue, 8 Sep 2026 23:05:57 +0200 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20downloadIcsFile=20rief=20nicht?= =?UTF-8?q?=20existierenden=20Endpoint=20auf=20=E2=80=94=20auf=20echten=20?= =?UTF-8?q?ics-feed=20umgestellt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Vorher: apiClient.get('/calendar/{id}/ics-feed-public') — Endpoint existiert im Backend nie (live 404 bewiesen via curl; Reverse-Check aus der Frontend-Backend-Gegenüberstellung) - Jetzt: nutzt getIcsFeedUrl() mit optionalem Token — derselbe Fluss wie IcsControls (Backend auto-generiert ics_token beim ersten Hit) - Funktion war tot (kein Aufrufer), aber garantiert kaputt für jeden künftigen Nutzer des Download-Buttons --- frontend/src/api/calendar.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/frontend/src/api/calendar.ts b/frontend/src/api/calendar.ts index d17f633..ef5de8a 100644 --- a/frontend/src/api/calendar.ts +++ b/frontend/src/api/calendar.ts @@ -263,9 +263,22 @@ export function getIcsFeedUrl(calendarId: string, token?: string | null): string return `${base}?token=${encodeURIComponent(token)}`; } -/** Fetch ICS file as text (used by "Download .ics" button). */ -export async function downloadIcsFile(calendarId: string, calendarName: string): Promise { - const response = await apiClient.get(`/calendar/${calendarId}/ics-feed-public`, { +/** Fetch ICS file as text (used by "Download .ics" button). + * + * Runtime-bug fix: this used to call `/calendar/{id}/ics-feed-public` — an + * endpoint that never existed in the backend (404, proven via curl). The + * real endpoint is `/calendar/{id}/ics-feed` and requires the calendar's + * ics token (the backend auto-generates one on first hit when the user has + * a session with calendar:read — same flow the IcsControls component uses + * via getIcsFeedUrl). + */ +export async function downloadIcsFile( + calendarId: string, + calendarName: string, + token?: string | null, +): Promise { + const feedUrl = getIcsFeedUrl(calendarId, token ?? null); + const response = await apiClient.get(feedUrl, { responseType: 'text', transformResponse: [(d) => d], });