From 9edfe24509d9ca1aca626cbb413cc9524630bca6 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Sun, 21 Jun 2026 10:44:08 +0200 Subject: [PATCH] fix(analytics, perf): fix umami proxy route redirect and remove blocking 10MB video preload to fix pagespeed --- app/[locale]/layout.tsx | 3 +-- app/stats/api/send/route.ts | 5 ++++- components/providers/InitialLoader.tsx | 28 +++----------------------- proxy.ts | 3 ++- 4 files changed, 10 insertions(+), 29 deletions(-) diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index d0b8b3f85..ee696f314 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -189,8 +189,7 @@ export default async function Layout(props: { - {/* Preload critical hero video */} - + diff --git a/app/stats/api/send/route.ts b/app/stats/api/send/route.ts index 3acd30f42..45d213224 100644 --- a/app/stats/api/send/route.ts +++ b/app/stats/api/send/route.ts @@ -40,7 +40,10 @@ export async function POST(request: NextRequest) { website: websiteId, }; - const umamiEndpoint = config.analytics.umami.apiEndpoint; + let umamiEndpoint = config.analytics.umami.apiEndpoint || 'https://analytics.infra.mintel.me'; + if (!umamiEndpoint.startsWith('http')) { + umamiEndpoint = `https://${umamiEndpoint}`; + } // Log the event (internal only) logger.debug('Forwarding analytics event', { diff --git a/components/providers/InitialLoader.tsx b/components/providers/InitialLoader.tsx index eeb11bcf5..4c7207061 100644 --- a/components/providers/InitialLoader.tsx +++ b/components/providers/InitialLoader.tsx @@ -4,9 +4,6 @@ import React, { useEffect, useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import Image from 'next/image'; -const PRELOAD_VIDEOS = [ - '/assets/videos/web/hero-bohrung.mp4' -]; export function InitialLoader({ shouldShowLoader = true }: { shouldShowLoader?: boolean }) { const [isLoading, setIsLoading] = useState(shouldShowLoader); @@ -14,30 +11,11 @@ export function InitialLoader({ shouldShowLoader = true }: { shouldShowLoader?: useEffect(() => { if (!shouldShowLoader) return; - // Fallback Timeout (4 Sekunden), falls Videos hängen + // Just show the animation for a short time to allow UI to mount, + // we don't preload 10MB videos anymore to save pagespeed! const timeout = setTimeout(() => { finishLoading(); - }, 4000); - - let videosLoaded = 0; - - const checkAllLoaded = () => { - videosLoaded++; - if (videosLoaded === PRELOAD_VIDEOS.length) { - clearTimeout(timeout); - // Kleine Verzögerung für die smootheness - setTimeout(finishLoading, 800); - } - }; - - PRELOAD_VIDEOS.forEach((src) => { - const video = document.createElement('video'); - video.preload = 'auto'; - video.oncanplaythrough = checkAllLoaded; - video.onerror = checkAllLoaded; // bei Fehler trotzdem weitermachen - video.src = src; - video.load(); - }); + }, 1200); // Cleanup return () => clearTimeout(timeout); diff --git a/proxy.ts b/proxy.ts index d3104af67..fae6aa4f9 100644 --- a/proxy.ts +++ b/proxy.ts @@ -9,8 +9,9 @@ export default createMiddleware({ export const config = { // Match all pathnames except for // - /api (API routes) + // - /stats (Analytics proxy) // - /_next (Next.js internals) // - /_static (inside /public) // - all root files inside /public (e.g. /favicon.ico) - matcher: ['/((?!api|_next|assets|_static|_vercel|[\\w-]+\\.\\w+).*)'] + matcher: ['/((?!api|stats|_next|assets|_static|_vercel|[\\w-]+\\.\\w+).*)'] };