Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved: app crashes on refresh after deployment #7 #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Tesfa-eth
Copy link

@Tesfa-eth Tesfa-eth commented Jan 12, 2023

Fixes #7

Replaced BrowserRouter with HashRouter. BrowserRouter is used for one-page website and that's why our app fails on refresh after deployment. Using HashRouter instead fixes the issue. Refer to StackOverflow for more information. This PR fixes the issue.

Replaced BrowserRouter with HashRouter
@Tesfa-eth Tesfa-eth changed the title Update App.js Solved: app crashes on refresh after deployment #7 Jan 12, 2023
@ajkeast
Copy link

ajkeast commented Mar 21, 2024

Thank you for this!

@Tesfa-eth
Copy link
Author

@ajkeast That is not the recommended solution though https://reactrouter.com/en/main/routers/create-hash-router. The right way to approach this issue is to Rewrites & Redirects option to the web service we are using. We want to make sure that when the page reloads, the app starts at index.html instead of that single page.

I'm currently using render.com and this worked for me

Source: /*
Destination: /index.html
Action: Rewrite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

App crashes on refresh after deployment
2 participants