Using Nuxt routeRules as a reverse proxy

Last updated:

|Edit this page

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.ts
export default defineNuxtConfig({
routeRules: {
'/ingest/**': { proxy: '**' },

Then configure the PostHog client to send requests via your new proxy:

const posthogClient = posthog.init(runtimeConfig.public.posthogPublicKey, {
api_host: '',
ui_host: '', // or if your PostHog is hosted in Europe


Was this page useful?

Next article

Product analytics for browser extensions

Do you have a Firefox or Chrome browser plugin with a user interface and want to understand how it's being used? PostHog is the perfect way to do just that. Setup for Firefox & Chrome plugins Installing PostHog inside your plugin Open the HTML file used in your default_popup and add the PostHog array.js script. To do this you'll need to either: Copy the latest version of array.js from: and import it locally using <script src="array.js" /> before…

Read next article