Skip to content

Commit

Permalink
fix(log): ignore /health init
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewuu committed Jan 15, 2025
1 parent 06d6e5b commit 844bbf0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/lib/log/axiom-request-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ const axiom = new Axiom({

export default function axiomRequestMiddleware(
middleware: NextMiddleware,
options: {
ignoredRoutes?: string[]
} = {},
): NextMiddleware {
return async (request, event) => {
const id = uuid()

if (options.ignoredRoutes?.includes(request.nextUrl.pathname)) {
return middleware(request, event)
}

const reqBody = await getBody(request)

axiom.ingest(process.env.NEXT_PUBLIC_AXIOM_DATASET!, [
Expand Down
5 changes: 4 additions & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const middleware = authMiddleware({

const withLogging =
process.env.NODE_ENV === 'production'
? loggingMiddleware(middleware)
? loggingMiddleware(middleware, {
// Do not log these routes
ignoredRoutes: ['/health'],
})
: middleware

export default withLogging
Expand Down

0 comments on commit 844bbf0

Please sign in to comment.