From fabb8c4213eaf2d9d04262658b2add0357ae2b5b Mon Sep 17 00:00:00 2001 From: Pranav Addepalli Date: Sun, 15 Jan 2023 22:11:06 -0500 Subject: [PATCH] Change application to run on subpath (#207) * added baseurl to application * small splash screen on / --- README.md | 1 + client/public/index.html | 1 + client/src/App.tsx | 2 +- client/src/components/navbar/Navbar.tsx | 6 +++--- client/src/components/navbar/OHQueueHeader.tsx | 2 +- client/src/http-common.tsx | 4 ++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a614182b..6d937d81 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ Create a `.env` file in the `client` folder with the following fields: | REACT_APP_DOMAIN | Domain used for the host address | | Angela | | REACT_APP_SOCKET_PATH | Path for sockets to use coming from the domain, usually ends with `/socket.io` | | Angela | | REACT_APP_SERVER_PATH | Path to make API calls to the server | | Angela | +| PUBLIC_URL | URL for where the application will run | | Pranav | Add them to the `.env` file like so: ``` diff --git a/client/public/index.html b/client/public/index.html index 1de4bcd4..0831608f 100644 --- a/client/public/index.html +++ b/client/public/index.html @@ -1,5 +1,6 @@ + diff --git a/client/src/App.tsx b/client/src/App.tsx index f92264d6..aae085a4 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -41,7 +41,7 @@ function App() { - + } /> } /> diff --git a/client/src/components/navbar/Navbar.tsx b/client/src/components/navbar/Navbar.tsx index 31660cb0..71cfe6ad 100644 --- a/client/src/components/navbar/Navbar.tsx +++ b/client/src/components/navbar/Navbar.tsx @@ -64,8 +64,8 @@ export default function Navbar(props) { const newPages = []; if (userData.isAuthenticated && userData.isTA) { - newPages.push(createPage('Settings', '/settings')); - newPages.push(createPage('Metrics', '/metrics')); + newPages.push(createPage('Settings', 'settings')); + newPages.push(createPage('Metrics', 'metrics')); } setPages(newPages); @@ -77,7 +77,7 @@ export default function Navbar(props) { function handleLogout() { removeCookie('user'); - window.location.href = '/'; + window.location.href = ''; } function openAlert() { diff --git a/client/src/components/navbar/OHQueueHeader.tsx b/client/src/components/navbar/OHQueueHeader.tsx index b1c6433f..b3ddb642 100644 --- a/client/src/components/navbar/OHQueueHeader.tsx +++ b/client/src/components/navbar/OHQueueHeader.tsx @@ -5,7 +5,7 @@ import { export default function OHQueueHeader() { return ( - + 15-122 Office Hours Queue ); diff --git a/client/src/http-common.tsx b/client/src/http-common.tsx index 527e1459..2e60b2af 100644 --- a/client/src/http-common.tsx +++ b/client/src/http-common.tsx @@ -29,7 +29,7 @@ httpInstance.interceptors.response.use( (res) => { if (res.data.isOwner && !window.location.href.includes('settings')) { // Redirect owner to settings page - window.location.href = '/settings'; + window.location.href = 'settings'; } // COMMENTED OUT SO ONLY TOAST IF ERROR // if (res.data.message) { @@ -40,7 +40,7 @@ httpInstance.interceptors.response.use( (err) => { if (err.response.status === 404) { // Redirect to homepage - window.location.href = '/'; + window.location.href = ''; } if (err.response.data.message) { const message = err.message + ': ' + err.response.data.message;