Skip to content
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

Plausible response is always a 202 #13

Open
thely opened this issue Jul 16, 2021 · 2 comments
Open

Plausible response is always a 202 #13

thely opened this issue Jul 16, 2021 · 2 comments

Comments

@thely
Copy link

thely commented Jul 16, 2021

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?

@luisfrocha
Copy link

luisfrocha commented Sep 9, 2021

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.

@moritzsternemann
Copy link
Owner

moritzsternemann commented Oct 23, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants