Skip to content

Commit

Permalink
fix: handle NEXT_NOT_FOUND & NEXT_REDIRECT errors
Browse files Browse the repository at this point in the history
We catch all errors and set statusCodes to 500s. This changes the
behavior to set the statusCodes to 404 or one of 307/308.
This fixes #219
  • Loading branch information
dasfmi committed Dec 13, 2024
1 parent a88fccf commit fef4a6d
Show file tree
Hide file tree
Showing 7 changed files with 707 additions and 525 deletions.
9 changes: 9 additions & 0 deletions examples/logger/app/api/notfound/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { AxiomRequest, withAxiom } from 'next-axiom';
import { notFound } from 'next/navigation';

export const runtime = 'nodejs';

// test handling NEXT_NOT_FOUND error
export const GET = withAxiom(async (req: AxiomRequest) => {
return notFound()
});
9 changes: 9 additions & 0 deletions examples/logger/app/api/permanentRedirect/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { AxiomRequest, withAxiom } from 'next-axiom';
import { permanentRedirect } from 'next/navigation';

export const runtime = 'nodejs';

// test handling NEXT_REDIRECT error with status code 308
export const GET = withAxiom(async (req: AxiomRequest) => {
return permanentRedirect('/')
});
10 changes: 10 additions & 0 deletions examples/logger/app/api/redirect/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { AxiomRequest, withAxiom } from 'next-axiom';
import { redirect } from 'next/navigation';

export const runtime = 'nodejs';


// test handling NEXT_REDIRECT error
export const GET = withAxiom(async (req: AxiomRequest) => {
return redirect('/')
});
Loading

0 comments on commit fef4a6d

Please sign in to comment.