-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reverse proxy support #42
Comments
Hi @andrei-vintila, thank you for your suggestion, it could bring value to this module. I'll gladly work on it starting next week, sorry for the delay 🙏 |
I have a PoC for these changes but I believe there is some API discussion we should have before finishing any implementation. We can already reverse proxy requests for the module using the following options in routeRules: {
'/ingest/ph/static/**': { proxy: 'https://eu-assets.i.posthog.com/static/**' },
'/ingest/ph/**': { proxy: 'https://eu.posthog.com/**' },
},
posthog: {
host: `${isDev ? 'http://localhost:3000' : process.env.URL}/ingest/ph`,
}, Note I don't like using a generic Given PostHog can be cloud-hosted in two regions (
Not sure how y'all envisioning this but I believe this second approach might be the best to account for customization of those rules and keep the module's codebase as simple as possible. It wouldn't do much but at least you'd be able to keep all your PostHog config in one place (vs |
@hacknug Good notes. Didn't consider the self-hosting use-case. I think that when you are self-hosting you kinda are already solving the issue that reverse proxy is trying to solve, meaning have a way that to "hide" this traffic under your own domain so that it is not blocked by uOrigin and similar trackers. So maybe we don't need to solve the self-hosting use-case. In my opinion, the biggest time saver is to figure out what is the base url in a way that works in all nitro deployment options. Option 1 with region where we infer the values sounds like the easiest way to do it.
I agree |
It's possible but I wouldn't assume adblockers won't ever block based on the URL. Self-hosted users might have their instance under
This is also true and I don't dislike the idea given everything else I mentioned.
Awesome! Let's wait to hear from Carles 👍 |
I agree it would be best if we provide some out-of-box solution to cover most cases. The idea of this module is to make the development process as easy and frictionless as possible. If the user wants to customize the behavior he would always be able to disable the default proxy and create his own using What do you think of the following: export default defineNuxtConfig({
posthog: {
proxy: {
enabled: boolean,
region: string,
},
},
}); Internally, we would: // Client bootsrap
if (config.proxy.enabled) {
clientOptions.api_host = `${isDev ? 'http://localhost:3000' : process.env.URL}/ingest/ph`;
clientOptions.ui_host = `https://${config.proxy.region}.posthog.com`;
}
// Module setup
if (options.proxy.enabled) {
nuxt.options.routeRules = defu(nuxt.options.routeRules, {
'/ingest/ph/static/**': { proxy: `https://${options.proxy.region}-assets.i.posthog.com/static/**` },
'/ingest/ph/**': { proxy: `https://${options.proxy.region}.i.posthog.com/**` },
});
} Not sure about having |
What about just calling it |
Hello there! Any news re. this topic? I'm facing the exact same issue where calls are blocked by blocker, and was expected reverse proxy out of the box. |
Basically add support for what is mentioned here.
By default it should be off as it will basically take all the posthog trafic and route it through the server that hosts nuxt.
The text was updated successfully, but these errors were encountered: