From 6a08e888afd7b54bd6feea92630ffb60e6e8c18d Mon Sep 17 00:00:00 2001 From: Arhan Ansari Date: Thu, 20 Nov 2025 19:49:57 +0530 Subject: [PATCH 1/5] Create main page component with layout and sections --- app/page.tsx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app/page.tsx diff --git a/app/page.tsx b/app/page.tsx new file mode 100644 index 0000000..6aee620 --- /dev/null +++ b/app/page.tsx @@ -0,0 +1,23 @@ +import Navbar from "@/components/Navbar"; +import Companies from "@/components/Sections/Companies"; +import HeroSection from "@/components/Sections/HeroSection"; +import Stats from "@/components/Sections/Stats"; +import { PricingTable } from "@clerk/nextjs"; +import React from "react"; + +const page = () => { + return ( +
+
+ +
+ + + + + {/* */} +
+ ); +}; + +export default page; From 074aa6192b4d8cabc3c1f8345d7380a4292128df Mon Sep 17 00:00:00 2001 From: Arhan Ansari Date: Thu, 20 Nov 2025 20:09:54 +0530 Subject: [PATCH 2/5] Update environment variable for URL --- lib/getBaseUrl.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lib/getBaseUrl.ts diff --git a/lib/getBaseUrl.ts b/lib/getBaseUrl.ts new file mode 100644 index 0000000..675f6b1 --- /dev/null +++ b/lib/getBaseUrl.ts @@ -0,0 +1,24 @@ +export function getBaseUrl() { + // 1. If running inside the browser, use relative path "/" + if (typeof window !== "undefined") { + return ""; + } + + // 2. If running on Vercel (deployment) + if (process.env.VERCEL_URL) { + return `https://${process.env.VERCEL_URL}`; + } + + // 3. If running on Appwrite Cloud Production & you set custom domain + if (process.env.NEXT_PUBLIC_APPWRITE_URL) { + try { + const url = new URL(process.env.NEXT_PUBLIC_APPWRITE_URL); + return `${url.origin}`; + } catch (error) { + console.error("Invalid APPWRITE endpoint:", error); + } + } + + // 4. Fallback for Local Development + return `http://localhost:${process.env.PORT ?? 3000}`; +} From 549fd5219643d001ea59e644a77aef50fb723dc4 Mon Sep 17 00:00:00 2001 From: Arhan Ansari Date: Thu, 20 Nov 2025 20:11:38 +0530 Subject: [PATCH 3/5] Refactor clerk middleware for public route handling Refactor authentication middleware to allow public routes and simplify base URL handling. --- proxy.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/proxy.ts b/proxy.ts index c2c8609..dc926c0 100644 --- a/proxy.ts +++ b/proxy.ts @@ -1,4 +1,5 @@ import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server"; +import { getBaseUrl } from "@/lib/getBaseUrl"; const isPublicRoute = createRouteMatcher([ "/sign-in(.*)", @@ -6,23 +7,22 @@ const isPublicRoute = createRouteMatcher([ "/sso-callback(.*)", "/api/webhooks(.*)", "/landing(.*)", + "/", // home page now public ]); export default clerkMiddleware(async (auth, req) => { - if (!isPublicRoute(req)) { - const baseUrl = - process.env.NODE_ENV === "production" - ? "https://your-domain.com" - : "http://localhost:3000"; - await auth.protect({ unauthenticatedUrl: `${baseUrl}/landing` }); - } + // Allow public routes + if (isPublicRoute(req)) return; + + // Redirect unauthed → /landing + /*await auth.protect({ + unauthenticatedUrl: `${getBaseUrl()}/landing` + });*/ }); export const config = { matcher: [ - // Skip Next.js internals and all static files, unless found in search params - "/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)", - // Always run for API routes + "/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|png|svg|woff2?|ico|csv|zip|webmanifest)).*)", "/(api|trpc)(.*)", ], }; From fcf89aa4e9cd793d6b98ac0b27b790a0046d9816 Mon Sep 17 00:00:00 2001 From: Arhan Ansari Date: Thu, 20 Nov 2025 20:15:51 +0530 Subject: [PATCH 4/5] Restore auth protection for non-public routes Re-enable authentication protection for routes. --- proxy.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/proxy.ts b/proxy.ts index dc926c0..88aa6b6 100644 --- a/proxy.ts +++ b/proxy.ts @@ -7,7 +7,6 @@ const isPublicRoute = createRouteMatcher([ "/sso-callback(.*)", "/api/webhooks(.*)", "/landing(.*)", - "/", // home page now public ]); export default clerkMiddleware(async (auth, req) => { @@ -15,9 +14,9 @@ export default clerkMiddleware(async (auth, req) => { if (isPublicRoute(req)) return; // Redirect unauthed → /landing - /*await auth.protect({ + await auth.protect({ unauthenticatedUrl: `${getBaseUrl()}/landing` - });*/ + }); }); export const config = { From 1afc4ec268cb6ce2e3593e008cf0a07bec63d9c9 Mon Sep 17 00:00:00 2001 From: Arhan Ansari Date: Thu, 20 Nov 2025 20:16:13 +0530 Subject: [PATCH 5/5] Delete app/page.tsx --- app/page.tsx | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 app/page.tsx diff --git a/app/page.tsx b/app/page.tsx deleted file mode 100644 index 6aee620..0000000 --- a/app/page.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import Navbar from "@/components/Navbar"; -import Companies from "@/components/Sections/Companies"; -import HeroSection from "@/components/Sections/HeroSection"; -import Stats from "@/components/Sections/Stats"; -import { PricingTable } from "@clerk/nextjs"; -import React from "react"; - -const page = () => { - return ( -
-
- -
- - - - - {/* */} -
- ); -}; - -export default page;