If you are using Next.js and rewrites aren't working for you, you can write custom middleware to proxy requests to PostHog.
To do this using the app router, create a file named middleware.js in your base directory (same level as the app folder). In this file, set up code to match requests to a custom route, set a new host header, change the URL to point to PostHog, and rewrite the response.
JavaScript
Once done, configure the PostHog client to send requests via your rewrite.
JavaScript