@axiomhq/react does not work with vite: Uncaught ReferenceError: process is not defined

React single-page app built with Vite, using @axiomhq/react together with @axiomhq/js and @axiomhq/logging. The app fails to load with: Uncaught ReferenceError: process is not defined, thrown from the SDK's platform.ts where it reads process.env. A workaround is adding define: { "process.env": process.env } to the Vite config, but that only papers over it.

The SDK read process.env directly, which does not exist in the browser. Workaround: define process.env in vite.config via the define option. Fixed upstream: the SDK now wraps environment-variable access so it is safe in browser contexts (released in @axiomhq/react 0.1.5); upgrading resolves it. Side note from the thread: a 403 from ingest means the token lacks permission for the dataset you are writing to, not a the local machine/proxy issue.

Source: https://github.com/axiomhq/axiom-js/issues/302

Source: https://github.com/axiomhq/axiom-js/issues/302