Skip to content

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