Skip to content

Commit a55f5a9

Browse files
committed
Add initiate login endpoint to /login
1 parent 25ad678 commit a55f5a9

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

src/app/actions/getSignInUrl.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/app/components/sign-in-button.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,10 @@
66

77
import { Button, Flex } from "@radix-ui/themes";
88
import { useAuth } from "@workos-inc/authkit-nextjs/components";
9-
import { useEffect, useState } from "react";
10-
import { getSignInUrlAction } from "../actions/getSignInUrl";
119
import { handleSignOutAction } from "../actions/signOut";
1210

1311
export function SignInButton({ large }: { large?: boolean }) {
1412
const { user, loading } = useAuth();
15-
const [signInUrl, setSignInUrl] = useState<string | undefined>(undefined);
16-
17-
useEffect(() => {
18-
getSignInUrlAction().then(setSignInUrl);
19-
}, []);
2013

2114
if (loading) {
2215
return <div>Loading...</div>;
@@ -36,7 +29,7 @@ export function SignInButton({ large }: { large?: boolean }) {
3629

3730
return (
3831
<Button asChild size={large ? "3" : "2"}>
39-
<a href={signInUrl}>Sign In {large && "with AuthKit"}</a>
32+
<a href="/login">Sign In {large && "with AuthKit"}</a>
4033
</Button>
4134
);
4235
}

src/app/login/route.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { getSignInUrl } from "@workos-inc/authkit-nextjs";
2+
import { redirect } from "next/navigation";
3+
4+
export const GET = async () => {
5+
const signInUrl = await getSignInUrl();
6+
7+
return redirect(signInUrl);
8+
};

0 commit comments

Comments
 (0)