Skip to content

Commit

Permalink
Change application to run on subpath (#207)
Browse files Browse the repository at this point in the history
* added baseurl to application

* small splash screen on /
  • Loading branch information
pranavaddepalli authored Jan 16, 2023
1 parent ccd20e9 commit fabb8c4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
```
Expand Down
1 change: 1 addition & 0 deletions client/public/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<base href="%PUBLIC_URL%/">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
Expand Down
2 changes: 1 addition & 1 deletion client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function App() {
<StudentDataContextProvider>
<AdminSettingsContextProvider>
<AllStudentsContextProvider>
<Router>
<Router basename={process.env.PUBLIC_URL}>
<Routes>
<Route path='/' element={<Home theme={theme || darkTheme}/>} />
<Route path='/settings' element={<Settings/>} />
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -77,7 +77,7 @@ export default function Navbar(props) {

function handleLogout() {
removeCookie('user');
window.location.href = '/';
window.location.href = '';
}

function openAlert() {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/navbar/OHQueueHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {

export default function OHQueueHeader() {
return (
<Link variant="h6" color="#FFFFFF" fontWeight='bold' href="/" underline="none" sx={{pt: 0.3}}>
<Link variant="h6" color="#FFFFFF" fontWeight='bold' href="" underline="none" sx={{pt: 0.3}}>
15-122 Office Hours Queue
</Link>
);
Expand Down
4 changes: 2 additions & 2 deletions client/src/http-common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit fabb8c4

Please sign in to comment.