Note: The following self-hosted proxy isn't provided by PostHog, so we can't take responsibility for it! If unsure, we recommend using our managed reverse proxy.
Note: If you are using the EU cloud then use
euinstead ofusin all domains (e.g.us.i.posthog.com->eu.i.posthog.com)
Vercel supports rewrites which we can use as a reverse proxy. Create a vercel.json file and add a rewrites object from the /ingest route.
Some frameworks, like SvelteKit and Astro, require a hungrier regex pattern like:
Note: Some frameworks, like T3 app, don't support Vercel rewrites well. If neither of these options work, we recommend trying another proxy method.
Once done, set the /ingest route of your domain as the API host in your PostHog initialization like this:
Once updated, deploy your changes on Vercel and check that PostHog requests are going to https://www.your-domain.com/ingest by checking the network tab on your domain.