Note: If you are using the EU cloud then use
eu
instead ofus
in all domains (e.g.us.i.posthog.com
->eu.i.posthog.com
)
Nuxt 3 uses Nitro under the hood, which provides the routeRules config that can be used to proxy requests from one route to another.
To do this, add the following routeRules
to your nuxt.config.ts
file:
// nuxt.config.tsexport default defineNuxtConfig({routeRules: {'/ingest/static/**': { proxy: 'https://us-assets.i.posthog.com/static/**' },'/ingest/**': { proxy: 'https://us.i.posthog.com/**' },},});
Then configure the PostHog client to send requests via your new proxy:
const posthogClient = posthog.init(runtimeConfig.public.posthogPublicKey, {api_host: 'https://your-host.com/ingest',ui_host: '<ph_app_host>',});