next-axiom: `withAxiom` does not support next.js' `basePath`

I have my next.js app set up with the basePath option meaning that it’s running on example.com/foo instead of example.com. Unfortunately, withAxiom sets up its endpoints in a way that does not seem to support basePath:

source: `${proxyPath}/web-vitals`,

where proxyPath = export const proxyPath = '/_axiom';.

I can see in the devtools’ network tab that the request is being fired at example.com/_axiom/web-vitals. Would it be possible to support the basePath option so that axiom’s requests would be fired at, e.g., example.com/foo/_axiom/web-vitals?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17

Commits related to this issue

Most upvoted comments

Yeah, you’re right, it’s going to be a proxy_pass from /_axiom to my_vercel_deployment/_axiom.

hmmm I don’t think that would work with the current solution. Nextjs won’t know what to do with /basePath/_axiom because it expects /_axiom directly. I am thinking maybe a proxy_pass is needed in nginx, to pass /_axiom to your_next_js/_axiom.

Either way - that’s not the scope of this fix, we can assume it’s working fine 😃 Thanks again for your help!

I have create a PR #46, and it worked 🥳

hi @klapec, let me check this out and get back to you. sorry for the late response, for some reason I didn’t see the issue when it was created.