Skip to content

Commit 74ae687

Browse files
committed
fix(posthog): read server PostHog config from env vars directly
The PR removed runtimeConfig.public.posthog from nuxt.config.ts since @posthog/nuxt manages it via posthogConfig. However server/utils/posthog.ts still referenced config.public.posthog?.publicKey/host which TypeScript no longer recognises (TS2339). Switch to process.env.POSTHOG_PUBLIC_KEY / POSTHOG_HOST directly — this is server-only code running in Nitro, which has full access to process.env, and avoids the redundant runtimeConfig round-trip.
1 parent 4c11f99 commit 74ae687

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

server/utils/posthog.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ let client: PostHog | null = null
1212
export function useServerPostHog(): PostHog | null {
1313
if (client) return client
1414

15-
const config = useRuntimeConfig()
16-
const publicKey = config.public.posthog?.publicKey
17-
const host = config.public.posthog?.host
15+
const publicKey = process.env.POSTHOG_PUBLIC_KEY
16+
const host = process.env.POSTHOG_HOST
1817

1918
if (!publicKey) {
2019
return null

0 commit comments

Comments
 (0)