NORY-26: error page not working (#40)
It still isn't the perfect error handling flow and I will have a look at it again at a later point in time, but for now the typical errors happening are caught and handled correctly.
This commit is contained in:
commit
65f04668f0
4 changed files with 10 additions and 14 deletions
|
@ -31,6 +31,9 @@ bun install
|
|||
bun run dev
|
||||
```
|
||||
|
||||
Create an account using the authentication UI on http://localhost:3000.
|
||||
The verification code can be found on the dummy SMTP dashboard on http://localhost:4436.
|
||||
|
||||
Inside another terminal session we can start the dashboard UI:
|
||||
|
||||
```bash
|
||||
|
|
|
@ -51,7 +51,7 @@ export default function Error() {
|
|||
|
||||
return (
|
||||
<>
|
||||
<Card>
|
||||
<Card className="mx-4 md:mx-8 max-w-5xl">
|
||||
<CardHeader>
|
||||
<CardTitle>An error occurred</CardTitle>
|
||||
</CardHeader>
|
||||
|
@ -61,7 +61,7 @@ export default function Error() {
|
|||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Button variant="ghost" asChild>
|
||||
<Button asChild>
|
||||
<Link href="/" className="inline-flex space-x-2" passHref>
|
||||
Go back
|
||||
</Link>
|
||||
|
|
|
@ -12,14 +12,13 @@ export async function middleware(request: NextRequest) {
|
|||
.then((response) => response.data)
|
||||
.catch(() => null);
|
||||
|
||||
const nodeHost = request.nextUrl.protocol + '//' + request.nextUrl.host;
|
||||
|
||||
if (!session && !request.nextUrl.pathname.startsWith('/flow')) {
|
||||
|
||||
console.log('NO SESSION');
|
||||
|
||||
const url = request.nextUrl.host +
|
||||
'/flow/login?return_to=' +
|
||||
request.nextUrl.host +
|
||||
request.nextUrl.pathname;
|
||||
const url = nodeHost + '/flow/login?return_to=' + request.nextUrl.toString();
|
||||
|
||||
console.log('REDIRECT TO', url);
|
||||
|
||||
|
@ -30,7 +29,7 @@ export async function middleware(request: NextRequest) {
|
|||
|
||||
console.log('SESSION EXISTS');
|
||||
|
||||
const returnTo = request.nextUrl.searchParams.get('return_to') ?? request.nextUrl.host;
|
||||
const returnTo = request.nextUrl.searchParams.get('return_to') ?? nodeHost;
|
||||
|
||||
console.log('REDIRECT TO', returnTo);
|
||||
|
||||
|
@ -41,5 +40,5 @@ export async function middleware(request: NextRequest) {
|
|||
}
|
||||
|
||||
export const config = {
|
||||
matcher: '/((?!api|_next/static|_next/image|favicon.png|sitemap.xml|robots.txt|sw.js).*)',
|
||||
matcher: '/((?!api|_next/static|_next/image|favicon.png|sitemap.xml|robots.txt|sw.js|manifest.json|icon-72.png|icon-128.png|icon-144.png|icon-192.png|icon-512.png|mt-logo-orange.png).*)',
|
||||
};
|
||||
|
|
|
@ -18,12 +18,6 @@ export const HandleError = (
|
|||
return async (
|
||||
error: AxiosError<any, unknown>,
|
||||
): Promise<AxiosError | void> => {
|
||||
if (!error.response || error.response?.status === 0) {
|
||||
window.location.href = `/flow/error?error=${encodeURIComponent(
|
||||
JSON.stringify(error.response),
|
||||
)}`;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const responseData = error.response?.data || {};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue