Register
diff --git a/apps/react-vite/src/features/auth/components/register-form.tsx b/apps/react-vite/src/features/auth/components/register-form.tsx
index 7529d7d2..caa1c7fe 100644
--- a/apps/react-vite/src/features/auth/components/register-form.tsx
+++ b/apps/react-vite/src/features/auth/components/register-form.tsx
@@ -3,6 +3,7 @@ import { Link, useSearchParams } from 'react-router-dom';
import { Button } from '@/components/ui/button';
import { Form, Input, Select, Label, Switch } from '@/components/ui/form';
+import { paths } from '@/config/paths';
import { useRegister, registerInputSchema } from '@/lib/auth';
import { Team } from '@/types/api';
@@ -106,7 +107,7 @@ export const RegisterForm = ({
Log In
diff --git a/apps/react-vite/src/features/discussions/components/discussions-list.tsx b/apps/react-vite/src/features/discussions/components/discussions-list.tsx
index 3c63e6f0..41d2c733 100644
--- a/apps/react-vite/src/features/discussions/components/discussions-list.tsx
+++ b/apps/react-vite/src/features/discussions/components/discussions-list.tsx
@@ -4,6 +4,7 @@ import { useSearchParams } from 'react-router-dom';
import { Link } from '@/components/ui/link';
import { Spinner } from '@/components/ui/spinner';
import { Table } from '@/components/ui/table';
+import { paths } from '@/config/paths';
import { formatDate } from '@/utils/format';
import { getDiscussionQueryOptions } from '../api/get-discussion';
@@ -64,7 +65,7 @@ export const DiscussionsList = ({
queryClient.prefetchQuery(getDiscussionQueryOptions(id));
onDiscussionPrefetch?.(id);
}}
- to={`./${id}`}
+ to={paths.app.discussion.getHref(id)}
>
View
diff --git a/apps/react-vite/src/lib/api-client.ts b/apps/react-vite/src/lib/api-client.ts
index aa0ecf73..86a60a27 100644
--- a/apps/react-vite/src/lib/api-client.ts
+++ b/apps/react-vite/src/lib/api-client.ts
@@ -2,6 +2,7 @@ import Axios, { InternalAxiosRequestConfig } from 'axios';
import { useNotifications } from '@/components/ui/notifications';
import { env } from '@/config/env';
+import { paths } from '@/config/paths';
function authRequestInterceptor(config: InternalAxiosRequestConfig) {
if (config.headers) {
@@ -31,8 +32,9 @@ api.interceptors.response.use(
if (error.response?.status === 401) {
const searchParams = new URLSearchParams();
- const redirectTo = searchParams.get('redirectTo');
- window.location.href = `/auth/login?redirectTo=${redirectTo}`;
+ const redirectTo =
+ searchParams.get('redirectTo') || window.location.pathname;
+ window.location.href = paths.auth.login.getHref(redirectTo);
}
return Promise.reject(error);
diff --git a/apps/react-vite/src/lib/auth.tsx b/apps/react-vite/src/lib/auth.tsx
index dfaec9a1..108e6728 100644
--- a/apps/react-vite/src/lib/auth.tsx
+++ b/apps/react-vite/src/lib/auth.tsx
@@ -2,6 +2,7 @@ import { configureAuth } from 'react-query-auth';
import { Navigate, useLocation } from 'react-router-dom';
import { z } from 'zod';
+import { paths } from '@/config/paths';
import { AuthResponse, User } from '@/types/api';
import { api } from './api-client';
@@ -79,11 +80,12 @@ export const ProtectedRoute = ({ children }: { children: React.ReactNode }) => {
const location = useLocation();
if (!user.data) {
+ console.log({
+ pathname: location.pathname,
+ redirectTo: paths.auth.login.getHref(location.pathname),
+ });
return (
-
+
);
}