From 97d1b25f01256834e6f405c981b6f03c15c16995 Mon Sep 17 00:00:00 2001 From: Julien Delaigues <0xju@pm.me> Date: Thu, 14 Mar 2024 11:19:30 +0800 Subject: [PATCH] chore: use reverse proxy --- next.config.js | 13 +++++++++++-- src/screens/app/index.tsx | 9 ++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/next.config.js b/next.config.js index 6f56624e..8948f3ff 100644 --- a/next.config.js +++ b/next.config.js @@ -38,11 +38,20 @@ const baseConfig = nextTranslate({ source: `${prefix}/native-staking`, })), ], - rewrites: async () => - ["/rss", "/rss/"].map((path) => ({ + rewrites: async () => [ + ...["/rss", "/rss/"].map((path) => ({ destination: "/rss.xml", source: path, })), + { + destination: "https://eu-assets.i.posthog.com/static/:path*", + source: "/ingest/static/:path*", + }, + { + destination: "https://eu.i.posthog.com/:path*", + source: "/ingest/:path*", + }, + ], typescript: { ignoreBuildErrors: process.env.QUICK_BUILD === "true", }, diff --git a/src/screens/app/index.tsx b/src/screens/app/index.tsx index fbb63ea0..fa04ee71 100644 --- a/src/screens/app/index.tsx +++ b/src/screens/app/index.tsx @@ -25,12 +25,14 @@ const MATOMO_SITE_ID = process.env.NEXT_PUBLIC_MATOMO_SITE_ID; // Check that PostHog is client-side (used to handle Next.js SSR) if (typeof window !== "undefined") { posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY as string, { - api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST, + api_host: `${window.location.origin}/ingest`, // Enable debug mode in development - loaded: (posthog) => { - if (process.env.NODE_ENV === "development") posthog.debug(); + loaded: (_posthog) => { + if (process.env.NODE_ENV === "development") _posthog.debug(); }, + + ui_host: process.env.NEXT_PUBLIC_POSTHOG_HOST, }); } @@ -59,6 +61,7 @@ export default function MyApp({ return () => { router.events.off("routeChangeComplete", handleRouteChange); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return (