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

withPlausibleProxy wrapper not forwarding country #75

Closed
alexandre-dos-reis opened this issue Nov 30, 2022 · 3 comments
Closed

withPlausibleProxy wrapper not forwarding country #75

alexandre-dos-reis opened this issue Nov 30, 2022 · 3 comments

Comments

@alexandre-dos-reis
Copy link

Hi @4lejandrito and thank you for your excellent work !

I tested the 2 methods described in the docs.

1° This config is working properly, I get all the data in my plausible dashboard.

_app.tsx

<PlausibleProvider
      domain="my-next.app"
      customDomain="https://my-plausible-self-hosted.app"
      selfHosted
    >
      {...rest_of_my_app}
</PlausibleProvider>

2° This method is working partially, I'm missing the countries data in my plausible dashboard.

_app.tsx

<PlausibleProvider
      domain="my-next.app"
      customDomain="https://my-plausible-self-hosted.app"
      selfHosted
    >
      {...rest_of_my_app}
</PlausibleProvider>

next.config.js

const { withPlausibleProxy } = require('next-plausible')

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
}

module.exports = withPlausibleProxy({
  customDomain: "https://my-plausible-self-hosted.app"
})(nextConfig)

I think this is caused by the second option not properly passing the header x-forwarded-for.

By the way, is the second config correct ?

Thank you.

@4lejandrito
Copy link
Owner

4lejandrito commented Dec 12, 2022

Hi @alexandre-dos-reis! Sorry for the late response.

  1. I think both methods look correct.
  2. Next plausible relies on nextjs rewrites to do the proxying. As far as I know all the headers are forwarded. I have no control over the headers. I think you might be able to tweak them through a middleware.

Let me know your findings.

@nealf
Copy link

nealf commented Jan 9, 2023

I also ran into this issue, where it seems the nextjs rewrites does not pass the correct X-Forwarded-For header during the proxying. I'm in the position that I have a workaround that proxies the plausible event traffic before it reaches the nextjs app.

I couldn't spend too much time investigating, but I did find this discussion with an open pull request mentioned from September 2022 that would allow custom headers, but I think @4lejandrito might be correct that as of NextJS v13, using middleware to add request headers is the best route. If I ever get around to trying it, I'll report back!

@4lejandrito
Copy link
Owner

I am closing this as there is little we can do on the library side.

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