You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20
Original file line number
Diff line number
Diff line change
@@ -209,6 +209,26 @@ For example, to send all logs except for debug logs to Axiom:
209
209
exportNEXT_PUBLIC_AXIOM_LOG_LEVEL=info
210
210
```
211
211
212
+
## Middleware tunneling (beta)
213
+
214
+
Axiom supports using `middleware.ts` files to proxy logs and webVitals to Axiom, this avoids the need to declare the `AXIOM_TOKEN` as a public environment variable.
215
+
216
+
To enable this feature, in your middleware.ts file, add the following code:
217
+
218
+
```ts
219
+
import { axiomMiddleware } from'next-axiom';
220
+
221
+
exportdefaultaxiomMiddleware();
222
+
223
+
exportconst config = {
224
+
matcher: '/_axiom/:path*', // Makes it so that the middleware only fires for requests that match this path
225
+
};
226
+
```
227
+
228
+
and in your environment variables, change the `NEXT_PUBLIC_AXIOM_TOKEN` to `AXIOM_TOKEN`.
229
+
230
+
This will proxy all requests to `/_axiom/logs` and `/_axiom/web-vitals` to Axiom using the middleware as a proxy layer.
231
+
212
232
## Capture errors
213
233
214
234
To capture routing errors, use the [error handling mechanism of Next.js](https://nextjs.org/docs/app/building-your-application/routing/error-handling):
0 commit comments