axiomhq / next-axiom

The official Next.js library for Axiom.
https://axiom.co/vercel
MIT License
357 stars 27 forks source link

405 (Method Not Allowed) on web vitals #213

Closed pepew-le-boss closed 2 months ago

pepew-le-boss commented 2 months ago

I'm using the NextJS integration and the withAxiom() function.

I can see all my logs in the axiom dashboard in production however each time I navigate to a page on my website I get this error in the console: POST https://www.my-website.com/fr/_axiom/web-vitals 405 (Method Not Allowed)

Is this because I add the [lang] param in the url ?

SollyzDev commented 2 months ago

yeah, perhaps that's the issue. You can try to build your rewrites object in a way that respects the language path. This is the one we provide with next-axiom:

https://github.com/axiomhq/next-axiom/blob/c1b8e117d80d7fb4c8df7e69d059970ba837c0ee/src/withAxiom.ts#L26-L37

pepew-le-boss commented 1 month ago

Because it's my middleware redirecting for internationalization purposes I just excluded the _axiom path in the matcher: matcher: ["/((?!api|_next/static|_next/image|images|favicon.ico|_axiom).*)"]

A lot easier than messing with rewrites 😂