You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When [first-party mode](/docs/guides/first-party) is enabled, PostHog requests are automatically proxied through your own server. This improves event capture reliability by avoiding ad blockers.
165
+
166
+
No additional configuration is needed — the module automatically sets `apiHost` to route through your server's proxy endpoint:
167
+
168
+
```ts
169
+
exportdefaultdefineNuxtConfig({
170
+
scripts: {
171
+
firstParty: true, // enabled by default
172
+
registry: {
173
+
posthog: {
174
+
apiKey: 'YOUR_API_KEY',
175
+
// apiHost is auto-set to '/_proxy/ph' (or '/_proxy/ph-eu' for EU region)
176
+
}
177
+
}
178
+
}
179
+
})
180
+
```
181
+
182
+
The proxy handles both API requests and static assets (e.g. session recording SDK), routing them to the correct PostHog endpoints.
183
+
184
+
## Custom API Host
185
+
186
+
To use a custom reverse proxy or self-hosted PostHog instance, set `apiHost` directly:
187
+
188
+
```ts
189
+
exportdefaultdefineNuxtConfig({
190
+
scripts: {
191
+
registry: {
192
+
posthog: {
193
+
apiKey: 'YOUR_API_KEY',
194
+
apiHost: '/my-proxy'
195
+
}
196
+
}
197
+
}
198
+
})
199
+
```
200
+
201
+
The `apiHost` option accepts any URL or relative path, overriding both the `region` default and the first-party proxy auto-configuration. For additional PostHog SDK options like `ui_host`, use the `config` passthrough.
202
+
161
203
## Feature Flags
162
204
163
205
Feature flag methods return values, so you need to wait for PostHog to load first:
0 commit comments