Fix/GitHub pages deploy #254
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request resolves the issue of the application failing to load on GitHub Pages (blank page) by introducing a robust and portable deployment
configuration. The changes ensure that the application works seamlessly on various static hosting platforms like GitHub Pages, Vercel, and Netlify
without requiring manual path adjustments.
Key Changes:
Dynamic Base Path in Vite (
vite.config.js
):The Vite configuration now uses a VITE_BASE_URL environment variable to set the base path. This makes the build artifact portable, as asset paths
are correctly resolved based on the deployment environment.
Explicit Router Configuration (
src/index.jsx
):The application's entry point has been updated to use an explicit router setup with createBrowserRouter. The router's basename is now
synchronized with the Vite base path via the same VITE_BASE_URL variable, ensuring client-side routing works correctly within the deployment
subdirectory.
GitHub Pages SPA Redirect (
public/404.html
):The 404.html file has been configured with a redirection script to handle client-side routing on GitHub Pages. This script intercepts 404 errors
on deep links (e.g., on page refresh) and redirects them to index.html, allowing the React Router to manage the route correctly.
CI/CD Workflow Enhancement (
.github/workflows/deploy.yml
):The deployment workflow has been improved in two ways:
maintenance-free.
How to Test: