bridge-school / cohort3-final-project-catcall

Other
1 stars 7 forks source link

On heroku only page refresh return "not found" message #43

Open KristenLutz opened 6 years ago

talyh commented 6 years ago

I've looked into different approaches, but I don't think we'll have a solution implemented before our code freeze. This was the closest I found - https://github.com/ReactTraining/react-router/issues/4977

However, as I understand it (which is not much), it expects a store to be created on the server side as well (which we don't right now), and then have different types of history (browser/memory) connected into the different stores (client/server).

I'd recommend that we keep it as a known issue for now so we don't risk breaking the app this close to the finish line..

stephanie56 commented 6 years ago

Thanks @talyh! Found this possible solution https://stackoverflow.com/questions/27928372/react-router-urls-dont-work-when-refreshing-or-writting-manually

Will need to switch to Hash History instead of using Browser History. Will try on my repo and see if it works. Bypassing the problem altogether: Hash History With Hash History instead of Browser History, your URL for the about page would look something like this: http://example.com/#/about The part after the hash (#) symbol is not sent to the server. So the server only sees http://example.com/ and sends the index page as expected. React-Router will pick up the #/about part and show the correct page.

talyh commented 6 years ago

From further research, it seems adding router.get('*', (req, res) => res.render('index')) to the server/routes/index.js (as the last route) would act as a catch-all, redirecting to the initial page.