feat(kilo-docs): add PostHog reverse proxy via Next.js rewrites

This commit is contained in:
Evan Jacobson
2026-03-12 12:50:57 -06:00
parent dd6ae52ed6
commit 3c6979c2f5
3 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -3,4 +3,4 @@ NEXT_PUBLIC_ALGOLIA_API_KEY=zyz6789
NEXT_PUBLIC_ALGOLIA_INDEX_NAME="Kilo Code Docs"
NEXT_PUBLIC_ALGOLIA_ASSISTANT_ID=foo-bar
NEXT_PUBLIC_POSTHOG_KEY=phc_QWERTY
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
# NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com # no longer needed; proxy via /ingest rewrites
+2 -1
View File
@@ -2,7 +2,8 @@ import posthog from "posthog-js"
if (process.env.NEXT_PUBLIC_POSTHOG_KEY) {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
api_host: "/ingest",
ui_host: "https://us.posthog.com",
person_profiles: "identified_only",
capture_pageview: false, // Handled manually in _app.tsx on routeChangeComplete
capture_pageleave: true,
+6
View File
@@ -5,6 +5,7 @@ module.exports = withMarkdoc(/* config: https://markdoc.io/docs/nextjs#options *
pageExtensions: ["js", "jsx", "ts", "tsx", "md", "mdoc"],
basePath: "/docs",
turbopack: {},
skipTrailingSlashRedirect: true,
async redirects() {
return [
{
@@ -30,6 +31,11 @@ module.exports = withMarkdoc(/* config: https://markdoc.io/docs/nextjs#options *
destination: "/api/llms.txt",
},
],
afterFiles: [
{ source: "/ingest/static/:path*", destination: "https://us-assets.i.posthog.com/static/:path*" },
{ source: "/ingest/decide", destination: "https://us.i.posthog.com/decide" },
{ source: "/ingest/:path*", destination: "https://us.i.posthog.com/:path*" },
],
}
},
})