Created
December 2, 2020 01:24
-
-
Save notepraiya/0e18e2dfa966d88a99627cbb0913ed15 to your computer and use it in GitHub Desktop.
deploying SPA with React/BrowserRouter to project-based github pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GitHub Pages doesn't natively support single page apps. When there is a fresh page load for a url like example.tld/foo, | |
where /foo is a frontend route, the GitHub Pages server returns 404 because it knows nothing of /foo | |
- https://github.com/contentful/gallery-app-react/issues/7#issue-483385870 | |
1. Edit package.json | |
Add "homepage": "https://notepraiya.github.io/react-beginner-chat", | |
2. Edit App.js | |
Add <BrowserRouter basename="/react-beginner-chat" > | |
3. inside build folder | |
Copy index.html to 404.html | |
- https://github.com/rafgraph/spa-github-pages | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment