diff --git a/AGENTS.md b/AGENTS.md index 2e60a577..486ce7ea 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -28,6 +28,11 @@ This project is a React-based web interface for the [Ergogen](https://github.com - **Centralized Theming**: All colors and other theme-related properties (e.g., font sizes, spacing) should be centralized in `src/theme/theme.ts`. Components should import and use variables from this theme file instead of using hardcoded values. - **Styled Components for Styling**: All styling, including global styles, should be managed using `styled-components`. Global styles should be defined in a `GlobalStyle` component to ensure consistency and encapsulation within the React component architecture, avoiding the use of separate CSS files like `index.css`. +## Architecture + +- **GitHub Pages Hosting**: The application is hosted on GitHub Pages, which only serves static files. This means that client-side routing needs a workaround to handle direct navigation to sub-paths. +- **404-based Redirect**: To handle client-side routing on GitHub Pages, a custom `public/404.html` file is used. This file contains a script that captures the requested path from `window.location.pathname`, stores it in `sessionStorage`, and then redirects the user to the root of the application (`/`). The main `App.tsx` component then reads this path from `sessionStorage` on load and navigates the user to the correct client-side route. + ## Development environment ### Linting and formatting diff --git a/e2e/routing.spec.ts b/e2e/routing.spec.ts index 7ef50d17..35f8feeb 100644 --- a/e2e/routing.spec.ts +++ b/e2e/routing.spec.ts @@ -90,4 +90,12 @@ test.describe('Routing and Welcome Page', () => { expect(parsed).toContain('points:'); }).toPass(); }); + + test('navigating directly to /new shows the welcome page after redirect', async ({ + page, + }) => { + await page.goto('/new'); + await expect(page).toHaveURL(/.*\/new/); + await expect(page.getByText('Welcome to Ergogen Web UI')).toBeVisible(); + }); }); diff --git a/public/404.html b/public/404.html new file mode 100644 index 00000000..a47eaefd --- /dev/null +++ b/public/404.html @@ -0,0 +1,19 @@ + + +
+ +