diff --git a/client/App.tsx b/client/App.tsx index 30be7dc..a37c947 100644 --- a/client/App.tsx +++ b/client/App.tsx @@ -12,7 +12,7 @@ import { ProfilePage } from './pages/Profile' const Redirect = ({ to }: { to: string }) => { useEffect(() => { - route(to, true) + route(prependBaseUrl(to), true) }, []) return ( diff --git a/client/pages/Admin.tsx b/client/pages/Admin.tsx index 324bbf9..5da4956 100644 --- a/client/pages/Admin.tsx +++ b/client/pages/Admin.tsx @@ -2,7 +2,7 @@ import { route } from 'preact-router' import { useState } from 'preact/hooks' import { isAdministrator, isStudent, Solution as SolutionModel, SolutionId } from '../../shared/model' import { sortByStringKey } from '../../shared/utils' -import { server } from '../api' +import { prependBaseUrl, server } from '../api' import { Header } from '../components/Header' import { MarkdownEditor } from '../components/MarkdownEditor' import { Select } from '../components/Select' @@ -16,7 +16,7 @@ const CreateProblem = ({}) => { content: source, }) - route(`/problem/${id}`) + route(prependBaseUrl(`/problem/${id}`)) } return ( @@ -32,9 +32,9 @@ type SortOrder = 'latest' | 'oldest' export const AdminPage = ({}) => { const [user] = useCurrentUser(user => { if (!user) { - route('/login', true) + route(prependBaseUrl('/login'), true) } else if (isStudent(user.role)) { - route('/', true) + route(prependBaseUrl('/'), true) } }) diff --git a/client/pages/Login.tsx b/client/pages/Login.tsx index 36f68c1..0959c28 100644 --- a/client/pages/Login.tsx +++ b/client/pages/Login.tsx @@ -1,6 +1,7 @@ import { route } from 'preact-router' import { useState } from 'preact/hooks' +import { prependBaseUrl } from '../api.js' import { Header } from '../components/Header.jsx' export const LoginPage = () => { @@ -18,7 +19,7 @@ export const LoginPage = () => { }), }) - route('/') + route(prependBaseUrl('/')) } return ( diff --git a/client/pages/Profile.tsx b/client/pages/Profile.tsx index ee5663e..4a95e0f 100644 --- a/client/pages/Profile.tsx +++ b/client/pages/Profile.tsx @@ -1,7 +1,7 @@ import { route } from 'preact-router' import { useState } from 'preact/hooks' import { isAdministrator, Solution as SolutionModel, User } from '../../shared/model' -import { server } from '../api' +import { prependBaseUrl, server } from '../api' import { Header } from '../components/Header' import { Select } from '../components/Select' import { Solution } from '../components/Solution' @@ -22,13 +22,13 @@ const SolutionList = ({ user }: { user: User }) => { export const ProfilePage = ({}) => { const [user, logout] = useCurrentUser(user => { if (!user) { - route('/login', true) + route(prependBaseUrl('/login'), true) } }) const handleLogout = () => { logout() - route('/') + route(prependBaseUrl('/')) } return (