I'm using Vercel analytics with NextJS. However, our sites are behind a cloudflare proxy, where clients can point any path they want off their domain to our NextJS app. Ex:
Our NextJS then rewrites the incoming urls to map them to the folder structure of our NextJS app.
When using analytics the request for the Javascript file always points to https://foobar.com/_vercel/analytics/script.js, which returns a 404 because we don't control that path on their domain.
I was able to get around this by using the HTML version, and our process.env.ASSET_PATH like this:
Is it possible to have both the script tag and the tracking event use the process.env.ASSET_PATH if one is set? Or at least have a way to configure where analytics send the tracking events?
I'm using Vercel
analytics
with NextJS. However, our sites are behind a cloudflare proxy, where clients can point any path they want off their domain to our NextJS app. Ex:https://foobar.com/shop -> proxy to our NextJS app
Our NextJS then rewrites the incoming urls to map them to the folder structure of our NextJS app.
When using
analytics
the request for the Javascript file always points to https://foobar.com/_vercel/analytics/script.js, which returns a 404 because we don't control that path on their domain.I was able to get around this by using the HTML version, and our process.env.ASSET_PATH like this:
so that the script is served up from our Vercel provided domain name.
This works, however, all the tracking events are still pointing to https://foobar.com/_vercel.
Is it possible to have both the script tag and the tracking event use the process.env.ASSET_PATH if one is set? Or at least have a way to configure where analytics send the tracking events?