vue-plausible icon indicating copy to clipboard operation
vue-plausible copied to clipboard

Plausible response is always a 202

Open thely opened this issue 4 years ago • 2 comments

I'm not sure if this is more relevant here or over on plausible-tracker, but I'm having a hell of a time getting this module working properly.

I'd like to just set a proxy to go straight to plausible.io/js/script.js, and it seemed like this package was part of the road to get there, but the instructions provided by this module don't apply to my use case. I'm not self-hosting Plausible, so setting apiHost to my domain will never work. Instead, I'm trying what seems like the right direction (though I have no idea), which is to set Plausible as normal, and set a proxy to go from my site to the Plausible API via nuxt-proxy. But no matter what I do, if I get anywhere close to right with either of these libraries, I'm only getting as far as 202 Accepted, and the traffic isn't registering on the dashboard.

Here are my current settings:

nuxt.config.js

...
plausible: {
    domain: "https://my-site-name.com",
},
proxy {
  "/api/event": {
      target: "https://plausible.io/api/event",
   },
},

Is this unnecessary? Is there some way to use the apiHost property to proxy without self-hosting, or is there something else I should be doing?

thely avatar Jul 16 '21 21:07 thely

I'm no authority on this, but I do believe it's unnecessary. I set mine up with just the domain, no proxy, and it works just fine.

luisfrocha avatar Sep 09 '21 11:09 luisfrocha

Hey @thely, sorry for getting back to you so late. This is not really an issue caused by this module, but more generally a combination of proxying and plausible-tracker. Though I think I can help you figure this out.

For this setup to work, there is no need to have a self-hosted Plausible instance. The goal here is for you to configure any web-server, that is under your control, to forward the plausible requests, so common ad- and tracking-blockers won't detect them. This can really be any server, for example a Cloudflare Worker, a Nginx reverse proxy in front of your Nuxt app, or the server component of your Nuxt app itself. You can find some example proxy configurations in the Plausible docs. When you use nuxt-proxy to forward the requests to the plausible API, your Nuxt app effectively becomes the apiHost.

Let's say your app is hosted at https://my-site-name.com. The proxy path you configured above is now available publicly at https://my-site-name.com/api/event, and forwards requests to the plausible endpoint. So in this case, the apiHost would need to be https://my-site-name.com as well.

Please let me know if anything is still unclear, or if there is an issue with this module.

moritzsternemann avatar Oct 23 '21 13:10 moritzsternemann