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
- fix/#29: set basePath to false in rewritres logs and webvitals are not working when nextjs basePath is set. As a solution for this, we would set basePath to false in our rewrites so it would be able t... — committed to axiomhq/next-axiom by schehata 2 years ago
- Merge pull request #46 from axiomhq/support-basePath fix/#29: set basePath to false in rewritres — committed to axiomhq/next-axiom by schehata 2 years ago
Yeah, you’re right, it’s going to be a proxy_pass from
/_axiom
tomy_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 toyour_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.