🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
fix build
Bill Yang93271df0346c
diff --git a/client/src/app/[site]/page.tsx b/client/src/app/[site]/page.tsxindex 10d53cc8d..c43988e85 100644--- a/client/src/app/[site]/page.tsx+++ b/client/src/app/[site]/page.tsx@@ -1,44 +1,16 @@-import { redirect } from "next/navigation";-import { Suspense } from "react";+"use client";-// Temporary loading component that will show while the redirect is processing-function Loading() {+import { useEffect } from "react";++// This is a simple fallback page that should never be seen+// All redirects should be handled by the middleware+export default function SiteRedirect() {return (<div className="min-h-screen flex items-center justify-center"><div className="text-center"><div className="inline-block w-12 h-12 border-4 border-blue-500 border-t-transparent rounded-full animate-spin"></div>- <p className="mt-4">Redirecting to dashboard...</p>+ <p className="mt-4">Redirecting...</p></div></div>);}--// This is now a Server Component (no "use client" directive)-export default function SiteRedirect({ params }: { params: { site: string } }) {- const siteId = params.site;-- if (siteId) {- // Server-side redirect using Next.js redirect function- redirect(`/${siteId}/main`);- }-- // This code will not execute if redirect is successful- return (- <Suspense fallback={<Loading />}>- <div className="min-h-screen flex items-center justify-center">- <div className="text-center">- <h1 className="text-xl font-bold mb-4">Redirect Failed</h1>- <p className="mb-4">Unable to navigate to the dashboard.</p>- {siteId && (- <a- href={`/${siteId}/main`}- className="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 inline-block"- >- Go to Dashboard- </a>- )}- </div>- </div>- </Suspense>- );-}diff --git a/client/src/middleware.ts b/client/src/middleware.tsindex d4931ea89..053c94070 100644--- a/client/src/middleware.ts+++ b/client/src/middleware.ts@@ -5,20 +5,46 @@ export function middleware(request: NextRequest) {const url = request.nextUrl.clone();const path = url.pathname;- // Check if we're on the exact site route (nothing after site name)+ // Skip redirects for static files (favicon.ico, images, etc.)+ if (path.includes(".")) {+ return NextResponse.next();+ }++ // Check if we're on a site route without a specific page+ // This matches exactly /{siteId} with nothing after itconst siteRoutePattern = /^\/([^/]+)$/;const match = path.match(siteRoutePattern);if (match) {const siteId = match[1];- // Redirect to the main page for this site- return NextResponse.redirect(new URL(`/${siteId}/main`, request.url));++ // Don't redirect certain built-in routes like 'login', 'signup', etc.+ const excludedRoutes = ["login", "signup", "settings", "_next", "api"];+ if (excludedRoutes.includes(siteId)) {+ return NextResponse.next();+ }++ // Add cache control headers to make sure the redirect isn't cached+ const response = NextResponse.redirect(+ new URL(`/${siteId}/main`, request.url)+ );+ response.headers.set("Cache-Control", "no-store, max-age=0");+ return response;}return NextResponse.next();}-// Only run middleware on specific paths to avoid unnecessary execution+// Only run middleware on specific paths, exclude asset pathsexport const config = {- matcher: "/:site",+ matcher: [+ /*+ * Match all request paths except for the ones starting with:+ * - _next/static (static files)+ * - _next/image (image optimization files)+ * - favicon.ico (favicon file)+ * - public files (images, etc.)+ */+ "/((?!_next/static|_next/image|favicon.ico|.*\\..*).*)",+ ],};