Thiimo
Thiimo
NNuxt
Created by Thiimo on 5/31/2024 in #❓・help
issue for nuxt proxy with Posthog
So I've been trying to get a reverse proxy setup for my analytics, but I keep getting this error:
{
"url": "/ingest/i/v0/e/?_=1717162970946&compression=gzip-js&ip=1&retry_count=1&ver=1.136.2",
"statusCode": 500,
"statusMessage": "",
"message": "fetch failed",
"stack": ""
}
{
"url": "/ingest/i/v0/e/?_=1717162970946&compression=gzip-js&ip=1&retry_count=1&ver=1.136.2",
"statusCode": 500,
"statusMessage": "",
"message": "fetch failed",
"stack": ""
}
I have a posthog.client.ts plugin with the following content
export default defineNuxtPlugin(() => {
const runtimeConfig = useRuntimeConfig()
const posthogClient = posthog.init(runtimeConfig.public.posthogPublicKey, {
api_host: '/ingest',
ui_host: 'https://eu.posthog.com',
capture_pageview: false,
loaded: (posthog) => {
if (import.meta.env.MODE === 'development')
posthog.debug()
},
})
})
export default defineNuxtPlugin(() => {
const runtimeConfig = useRuntimeConfig()
const posthogClient = posthog.init(runtimeConfig.public.posthogPublicKey, {
api_host: '/ingest',
ui_host: 'https://eu.posthog.com',
capture_pageview: false,
loaded: (posthog) => {
if (import.meta.env.MODE === 'development')
posthog.debug()
},
})
})
and in my nuxt.config.ts I have the following route rules:
export default defineNuxtConfig({
routeRules: {
'/ingest/static/**': {
proxy: 'https://eu-assets.i.posthog.com/static/**',
},
'/ingest/**': {
proxy: 'https://eu.i.posthog.com/**',
},
},
})
export default defineNuxtConfig({
routeRules: {
'/ingest/static/**': {
proxy: 'https://eu-assets.i.posthog.com/static/**',
},
'/ingest/**': {
proxy: 'https://eu.i.posthog.com/**',
},
},
})
2 replies
NNuxt
Created by Thiimo on 3/11/2024 in #❓・help
How to assert non-null with data fetching
No description
5 replies