From 56c05cc8fc1d0da053eaa1cb9bd16ca5075dd7a8 Mon Sep 17 00:00:00 2001 From: Unchained Date: Tue, 31 Mar 2026 05:17:57 +0200 Subject: [PATCH] feat(analytics): add Rybbit proxy rewrites and env vars - Add Next.js rewrites to proxy /api/script.js and /api/track through self-hosted Rybbit - This bypasses ad blockers that would block rybbit.nodecrew.me directly - Add NEXT_PUBLIC_RYBBIT_HOST and NEXT_PUBLIC_RYBBIT_SITE_ID env vars to K8s deployment --- k8s/deployment.yaml | 4 ++++ next.config.ts | 13 +++++++++++++ src/app/[locale]/layout.tsx | 7 +++---- src/lib/services/RybbitService.ts | 4 ++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index 0c41fa3..55e4f48 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -126,6 +126,10 @@ spec: value: "91126be0d1e78e657e0427df82733832.c6d30edf6ee673da9650a883604169a13ab8579a0dde70cb39b477f4cf441f90" - name: OPENPANEL_API_URL value: "https://op.nodecrew.me/api" + - name: NEXT_PUBLIC_RYBBIT_HOST + value: "https://rybbit.nodecrew.me" + - name: NEXT_PUBLIC_RYBBIT_SITE_ID + value: "1" resources: limits: cpu: 500m diff --git a/next.config.ts b/next.config.ts index 25217ff..1f74dce 100644 --- a/next.config.ts +++ b/next.config.ts @@ -5,6 +5,19 @@ const withNextIntl = createNextIntlPlugin(); const nextConfig: NextConfig = { output: 'standalone', + async rewrites() { + const rybbitHost = process.env.NEXT_PUBLIC_RYBBIT_HOST || "https://rybbit.nodecrew.me"; + return [ + { + source: "/api/script.js", + destination: `${rybbitHost}/api/script.js`, + }, + { + source: "/api/track", + destination: `${rybbitHost}/api/track`, + }, + ]; + }, images: { remotePatterns: [ { diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index ed95341..0d891c3 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -5,9 +5,8 @@ import { SUPPORTED_LOCALES, DEFAULT_LOCALE, isValidLocale } from "@/lib/i18n/loc import { OpenPanelComponent } from "@openpanel/nextjs"; import Script from "next/script"; -// Rybbit configuration - defined inline to avoid client directive issues -const RYBBIT_HOST = "https://rybbit.nodecrew.me"; -const RYBBIT_SITE_ID = "1"; +// Rybbit configuration +const RYBBIT_SITE_ID = process.env.NEXT_PUBLIC_RYBBIT_SITE_ID || "1"; const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://manoonoils.com"; @@ -59,7 +58,7 @@ export default async function LocaleLayout({ scriptUrl="https://op.nodecrew.me/op1.js" />