Skip to content

Commit 7da1d29

Browse files
Merge pull request #12 from Eric-Zhang-Developer/fix/vercel-routing-auth
Fix/vercel routing auth
2 parents 0e71e38 + fedc4eb commit 7da1d29

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

src/app/dashboard/page.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,15 @@ export default async function DashboardPage() {
2727
<span>Home</span>
2828
</Link>
2929
<form action={logout}>
30-
<button
31-
type="submit"
32-
className="btn btn-neutral btn-outline"
33-
>
30+
<button type="submit" className="btn btn-neutral btn-outline">
3431
<span>Log out</span>
3532
</button>
3633
</form>
3734
</div>
38-
39-
4035

4136
<p className="mt-4 text-neutral-600">
42-
You're logged in as: <span className="font-bold">{user.email}</span>.
37+
You&apos;re logged in as: <span className="font-bold">{user.email}</span>.
4338
</p>
44-
4539
</main>
4640
);
4741
}

src/app/login/page.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,18 @@ export default function AuthPage() {
2525
if (error) throw error;
2626
} else {
2727
const { error } = await supabase.auth.signUp({ email, password });
28-
if (error) throw error;
28+
if (error) throw error;
2929
}
3030
router.push("/dashboard");
31-
} catch (e: any) {
32-
setErr(e?.message ?? "Something went wrong");
31+
} catch (e: unknown) {
32+
let errorMessage = "Something went wrong. Please try again";
33+
34+
if (e instanceof Error) {
35+
errorMessage = e.message;
36+
} else if (typeof e === "string") {
37+
errorMessage = e;
38+
}
39+
setErr(errorMessage);
3340
} finally {
3441
setBusy(false);
3542
}
@@ -55,14 +62,12 @@ export default function AuthPage() {
5562
>
5663
Sign up
5764
</button>
58-
</div>
65+
</div>
5966

6067
{/* Optional info for signup */}
6168
{mode === "signup" && (
6269
<div role="alert" className="alert alert-soft mb-2">
63-
<span>
64-
Create an account with email & password.
65-
</span>
70+
<span>Create an account with email & password.</span>
6671
</div>
6772
)}
6873

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function TutorialHelloWorld() {
2+
return (
3+
<>
4+
<h1>Hello World</h1>
5+
</>
6+
);
7+
}

0 commit comments

Comments
 (0)