diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index bb3686d77..c9c763b22 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -14,7 +14,6 @@ on: - 'index.html' - 'vite.config.js' - concurrency: preview-${{ github.ref }} jobs: @@ -38,33 +37,33 @@ jobs: fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + deploy-preview: runs-on: ubuntu-latest needs: check_access if: needs.check_access.outputs.level == 'write' || needs.check_access.outputs.level == 'admin' - + strategy: matrix: node-version: [18] - + steps: - name: ⏬ Checkout uses: actions/checkout@v3 - + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} registry-url: 'https://registry.npmjs.org' cache: 'npm' - + - name: ⚙️ Install and Build run: | export GH_BASE_URL="/teia-ui/previews/pr-${{ github.event.pull_request.number }}/" npm ci npm run build - + - name: Deploy preview uses: rossjrw/pr-preview-action@v1 with: diff --git a/src/index.jsx b/src/index.jsx index f0cc5d5f3..518f9759a 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -52,6 +52,7 @@ import { Terms } from '@pages/terms' import ReactDOM from 'react-dom/client' import { createBrowserRouter, + createHashRouter, createRoutesFromElements, Route, RouterProvider, @@ -73,7 +74,10 @@ const display_routes = ( ) //TODO(mel): Check/Update site map / robot.txt -const router = createBrowserRouter( + +const routerCreator = + import.meta.env.BASE_URL === '/' ? createBrowserRouter : createHashRouter +const router = routerCreator( createRoutesFromElements( } element={}> } /> @@ -146,7 +150,10 @@ const router = createBrowserRouter( {display_routes} - ) + ), + { + basename: import.meta.env.BASE_URL, + } ) ReactDOM.createRoot(document.getElementById('root')).render(