diff --git a/website/.env.example b/website/.env.example index 03937ed..bf2d1bd 100644 --- a/website/.env.example +++ b/website/.env.example @@ -1,4 +1,5 @@ # Umami Analytics # Get these from your Umami dashboard: Settings → Websites → Edit -NEXT_PUBLIC_UMAMI_URL=https://your-umami-instance.com/script.js +# The script is proxied through /stats/ to bypass ad blockers (see next.config.mjs) +NEXT_PUBLIC_UMAMI_HOST=cloud.umami.is NEXT_PUBLIC_UMAMI_WEBSITE_ID=your-website-id-here diff --git a/website/next.config.mjs b/website/next.config.mjs index 8cdec10..06ee384 100644 --- a/website/next.config.mjs +++ b/website/next.config.mjs @@ -5,4 +5,14 @@ const withNextra = nextra({ themeConfig: './theme.config.tsx', }) -export default withNextra() +export default withNextra({ + async rewrites() { + const umamiHost = process.env.NEXT_PUBLIC_UMAMI_HOST || 'cloud.umami.is' + return [ + { + source: '/stats/:path*', + destination: `https://${umamiHost}/:path*`, + }, + ] + }, +}) diff --git a/website/pages/_app.tsx b/website/pages/_app.tsx index 14893c8..0f41572 100644 --- a/website/pages/_app.tsx +++ b/website/pages/_app.tsx @@ -2,14 +2,13 @@ import type { AppProps } from 'next/app' import Script from 'next/script' export default function App({ Component, pageProps }: AppProps) { - const umamiUrl = process.env.NEXT_PUBLIC_UMAMI_URL const umamiWebsiteId = process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID return ( <> - {umamiUrl && umamiWebsiteId && ( + {umamiWebsiteId && (