Pārlūkot izejas kodu

fix: add BASE_URL prefix to all hardcoded navigation paths

All window.location.href assignments and plain <a href> attributes now
use import.meta.env.BASE_URL so redirects land at /chat/dashboard,
/chat/login, etc. instead of the root domain.

Files fixed: Login.tsx, Register.tsx, DashboardLayout.tsx,
AcceptInvite.tsx, UserManagement.tsx

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tony T 1 nedēļu atpakaļ
vecāks
revīzija
cf0de9b89c

+ 3 - 2
client/src/components/DashboardLayout.tsx

@@ -85,8 +85,9 @@ export default function DashboardLayout({
 
   if (!user) {
     // Redirect to login page with return URL
+    const base = import.meta.env.BASE_URL ?? "/";
     const currentPath = window.location.pathname;
-    window.location.href = `/login?returnTo=${encodeURIComponent(currentPath)}`;
+    window.location.href = `${base}login?returnTo=${encodeURIComponent(currentPath)}`;
     return <DashboardLayoutSkeleton />;
   }
 
@@ -135,7 +136,7 @@ export default function DashboardLayout({
               </div>
             </div>
             <Button
-              onClick={() => { window.location.href = "/"; }}
+              onClick={() => { window.location.href = import.meta.env.BASE_URL ?? "/"; }}
               variant="outline"
               className="w-full"
               style={{ borderColor: "#e7e0d5" }}

+ 1 - 1
client/src/pages/AcceptInvite.tsx

@@ -196,7 +196,7 @@ export default function AcceptInvite() {
                 You need to sign in first to accept this invitation.
               </p>
               <a
-                href={`/login?returnTo=${encodeURIComponent(`/invite/${token}`)}`}
+                href={`${import.meta.env.BASE_URL ?? "/"}login?returnTo=${encodeURIComponent(`/invite/${token}`)}`}
                 className="flex items-center justify-center gap-2 w-full px-4 py-2.5 rounded-xl text-sm font-semibold text-white transition-colors"
                 style={{ background: "#14532D" }}
               >

+ 3 - 2
client/src/pages/Login.tsx

@@ -39,7 +39,8 @@ export default function Login() {
     onSuccess: () => {
       // Redirect to dashboard after login
       const params = new URLSearchParams(window.location.search);
-      const returnTo = params.get("returnTo") || "/dashboard";
+      const base = import.meta.env.BASE_URL ?? "/";
+      const returnTo = params.get("returnTo") || `${base}dashboard`;
       window.location.href = returnTo;
     },
     onError: (err) => {
@@ -49,7 +50,7 @@ export default function Login() {
 
   // Redirect if already logged in
   if (!authLoading && isAuthenticated) {
-    window.location.href = "/dashboard";
+    window.location.href = `${import.meta.env.BASE_URL ?? "/"}dashboard`;
     return null;
   }
 

+ 2 - 2
client/src/pages/Register.tsx

@@ -39,7 +39,7 @@ export default function Register() {
 
   const registerMutation = trpc.auth.register.useMutation({
     onSuccess: () => {
-      window.location.href = "/dashboard";
+      window.location.href = `${import.meta.env.BASE_URL ?? "/"}dashboard`;
     },
     onError: (err) => {
       setError(err.message || "Registration failed");
@@ -48,7 +48,7 @@ export default function Register() {
 
   // Redirect if already logged in
   if (!authLoading && isAuthenticated) {
-    window.location.href = "/dashboard";
+    window.location.href = `${import.meta.env.BASE_URL ?? "/"}dashboard`;
     return null;
   }
 

+ 2 - 1
client/src/pages/UserManagement.tsx

@@ -676,7 +676,8 @@ function InvitationsTab() {
   }, [invitationsList, statusFilter]);
 
   const copyInviteLink = (token: string) => {
-    const link = `${window.location.origin}/invite/${token}`;
+    const base = import.meta.env.BASE_URL ?? "/";
+    const link = `${window.location.origin}${base}invite/${token}`;
     navigator.clipboard.writeText(link);
     toast.success("Invite link copied to clipboard");
   };