-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle NEXT_NOT_FOUND & NEXT_REDIRECT errors
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
Showing
7 changed files
with
707 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('/') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('/') | ||
}); |
Oops, something went wrong.