Skip to content

Commit f7e6e5d

Browse files
authored
Merge pull request #10 from workos/paulasjes/auth-error-page
Added error page on callback error
2 parents 58c2bd8 + 12fd54c commit f7e6e5d

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"@radix-ui/react-icons": "^1.3.0",
1213
"@radix-ui/themes": "^2.0.1",
1314
"@workos-inc/node": "^5.0.0",
1415
"jose": "^5.1.1",

src/app/callback/route.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ export async function GET(request: NextRequest) {
4747
error: error instanceof Error ? error.message : String(error),
4848
};
4949
console.error(errorRes);
50-
return NextResponse.json(errorRes);
50+
return NextResponse.redirect(new URL("/error", request.url));
5151
}
5252
}
5353

54-
return NextResponse.json({
55-
error: "No authorization code was received from AuthKit",
56-
});
54+
return NextResponse.redirect(new URL("/error", request.url));
5755
}

src/app/error/page.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {
2+
Text,
3+
Heading,
4+
Flex,
5+
CalloutRoot,
6+
CalloutIcon,
7+
CalloutText,
8+
Container,
9+
} from "@radix-ui/themes";
10+
import { ExclamationTriangleIcon } from "@radix-ui/react-icons";
11+
12+
export default function ErrorPage() {
13+
return (
14+
<Flex gap="4" direction="column" style={{ maxWidth: "430px" }}>
15+
<Heading size="8">Error</Heading>
16+
<Container>
17+
<CalloutRoot color="red" role="alert">
18+
<CalloutIcon>
19+
<ExclamationTriangleIcon />
20+
</CalloutIcon>
21+
<CalloutText>Something went wrong</CalloutText>
22+
</CalloutRoot>
23+
</Container>
24+
<Container>
25+
<Text size="3" align="center" color="gray">
26+
Couldn’t sign in. If you are not sure what happened, please contact
27+
your organization admin.
28+
</Text>
29+
</Container>
30+
</Flex>
31+
);
32+
}

0 commit comments

Comments
 (0)