diff --git a/src/app/page.tsx b/src/app/page.tsx index 6cec9f60..1b7604eb 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,4 +1,6 @@ -import Home from "@/components/home/home"; +import LandingPage from "@/components/Landing"; +// import Home from "@/components/home/home"; + export default function page() { - return ; + return ; } diff --git a/src/components/Landing.tsx b/src/components/Landing.tsx new file mode 100644 index 00000000..34be84c9 --- /dev/null +++ b/src/components/Landing.tsx @@ -0,0 +1,57 @@ +import Image from "next/image"; +import Link from "next/link"; +import { Button } from "@/components/ui/button"; + +export default function LandingPage() { + return ( +
+ {/* Hero Section */} +
+ {/* Background Pattern */} +
+ AIBTC Background Pattern +
+ + {/* Content overlay */} +
+
+ {/* Logo */} +
+ AIBTC Logo +
+ + {/* Button */} + + + +
+
+
+
+ ); +} diff --git a/src/utils/supabase/middleware.ts b/src/utils/supabase/middleware.ts index 902d8b43..736b1a0b 100644 --- a/src/utils/supabase/middleware.ts +++ b/src/utils/supabase/middleware.ts @@ -1,53 +1,57 @@ -import { createServerClient } from "@supabase/ssr"; -import { type NextRequest, NextResponse } from "next/server"; +import { createServerClient } from "@supabase/ssr" +import { type NextRequest, NextResponse } from "next/server" export const updateSession = async (request: NextRequest) => { try { + // If the path is not the root path, redirect to root + if (request.nextUrl.pathname !== "/") { + return NextResponse.redirect(new URL("/", request.url)) + } + // Create an unmodified response let response = NextResponse.next({ request: { headers: request.headers, }, - }); + }) - const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL; - const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY; + const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL + const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY if (!supabaseUrl || !supabaseAnonKey) { - throw new Error( - "middleware: missing supabase url or supabase anon key in env vars" - ); + throw new Error("middleware: missing supabase url or supabase anon key in env vars") } const supabase = createServerClient(supabaseUrl, supabaseAnonKey, { cookies: { getAll() { - return request.cookies.getAll(); + return request.cookies.getAll() }, setAll(cookiesToSet) { - cookiesToSet.forEach(({ name, value }) => - request.cookies.set(name, value) - ); + cookiesToSet.forEach(({ name, value }) => request.cookies.set(name, value)) response = NextResponse.next({ request, - }); - cookiesToSet.forEach(({ name, value, options }) => - response.cookies.set(name, value, options) - ); + }) + cookiesToSet.forEach(({ name, value, options }) => response.cookies.set(name, value, options)) }, }, - }); + }) // Get the user - const { - data: { user }, - error: userError, - } = await supabase.auth.getUser(); + // const { + // data: { user }, + // error: userError, + // } = await supabase.auth.getUser() + // Still call getUser() to refresh the session, but don't store the result + await supabase.auth.getUser() + + // ORIGINAL ROUTE PROTECTION LOGIC (COMMENTED OUT) + /* // If trying to access admin route if (request.nextUrl.pathname.startsWith("/admin")) { if (userError || !user) { // If no user, redirect to login - return NextResponse.redirect(new URL("/daos", request.url)); + return NextResponse.redirect(new URL("/", request.url)) } // Check user role in profiles table @@ -55,11 +59,11 @@ export const updateSession = async (request: NextRequest) => { .from("profiles") .select("role") .eq("id", user.id) - .single(); + .single() if (profileError || !profileData || profileData.role !== "Admin") { // If not admin, redirect to dashboard - return NextResponse.redirect(new URL("/chat", request.url)); + return NextResponse.redirect(new URL("/chat", request.url)) } } @@ -74,25 +78,26 @@ export const updateSession = async (request: NextRequest) => { // } // Redirect root route to /daos - if (request.nextUrl.pathname === "/") { - return NextResponse.redirect(new URL("/daos", request.url)); - } + // if (request.nextUrl.pathname === "/") { + // return NextResponse.redirect(new URL("/daos", request.url)); + // } if (request.nextUrl.pathname.startsWith("/profile") && (userError || !user)) { return NextResponse.redirect(new URL("/", request.url)) } if (request.nextUrl.pathname === "/" && !userError) { - return NextResponse.redirect(new URL("/daos", request.url)); + return NextResponse.redirect(new URL("/daos", request.url)) } + */ - return response; + return response } catch (error) { - console.error(error); + console.error(error) return NextResponse.next({ request: { headers: request.headers, }, - }); + }) } -}; \ No newline at end of file +}