+ Something went wrong while signing you in. This could happen if the login was cancelled or
+ took too long.
+
+
+ Try Again
+
+
+
+ );
+}
diff --git a/src/app/auth/callback/route.ts b/src/app/auth/callback/route.ts
new file mode 100644
index 0000000..861316d
--- /dev/null
+++ b/src/app/auth/callback/route.ts
@@ -0,0 +1,33 @@
+import { NextResponse } from "next/server";
+// The client you created from the Server-Side Auth instructions
+import { createClient } from "@/lib/supabase/server";
+export async function GET(request: Request) {
+ const { searchParams, origin } = new URL(request.url);
+ const code = searchParams.get("code");
+ // if "next" is in param, use it as the redirect URL
+ let next = searchParams.get("next") ?? "/";
+ if (!next.startsWith("/")) {
+ // if "next" is not a relative URL, use the default
+ next = "/";
+ }
+
+ if (code) {
+ const supabase = await createClient();
+ const { error } = await supabase.auth.exchangeCodeForSession(code);
+ if (!error) {
+ const forwardedHost = request.headers.get("x-forwarded-host"); // original origin before load balancer
+ const isLocalEnv = process.env.NODE_ENV === "development";
+ if (isLocalEnv) {
+ // we can be sure that there is no load balancer in between, so no need to watch for X-Forwarded-Host
+ return NextResponse.redirect(`${origin}${next}`);
+ } else if (forwardedHost) {
+ return NextResponse.redirect(`https://${forwardedHost}${next}`);
+ } else {
+ return NextResponse.redirect(`${origin}${next}`);
+ }
+ }
+ }
+
+ // return the user to an error page with instructions
+ return NextResponse.redirect(`${origin}/auth/auth-code-error`);
+}
diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx
index 5e886a3..21f34eb 100644
--- a/src/app/login/page.tsx
+++ b/src/app/login/page.tsx
@@ -3,6 +3,8 @@
import { useState } from "react";
import { useRouter } from "next/navigation";
import { createClient } from "../../lib/supabase/client";
+import handleOAuthLogin from "@/lib/supabase/handle-oauth-login";
+import { FaGoogle, FaGithub } from "react-icons/fa";
export default function AuthPage() {
const router = useRouter();
@@ -43,7 +45,7 @@ export default function AuthPage() {
className="min-h-dvh flex items-center justify-center bg-cover bg-center bg-no-repeat p-6 font-cinzel text-white"
style={{ backgroundImage: "url('/geminiblurred.png')" }}
>
-
+
{mode === "login" ? "Welcome Back" : "Create Your Account"}
@@ -82,7 +84,7 @@ export default function AuthPage() {