3

I am trying to build a SPA with react router. When I am navigating with link it works perfect, but with refreshing or writting url it gives me cannot GET /(any route except main). I was trying to add historyApiFallback : true option to my webpack dev server configs but it didnt solved it.

I will appreciate any help.

Deni Chan
  • 75
  • 1
  • 8

3 Answers3

2

This is documented (and now I have written 30 characters): https://github.com/reactjs/react-router/blob/v2.3.0/docs/guides/Histories.md#browserhistory

Ryan Florence
  • 13,361
  • 9
  • 46
  • 63
  • Thank you, Ryan!!! I wrote a server using your example, but I faced another problem. I got an `unexpected < token ` error . After I added type=text/jsx to my script tag in index.html, no errors but page just doesnt displaying after refreshing... – Deni Chan Apr 21 '16 at 20:48
1

Perhaps this is your issue? React-router urls don't work when refreshing or writting manually

It might be helpful if you included the code from your router in the question as well.

Community
  • 1
  • 1
Charlie Weems
  • 1,682
  • 1
  • 16
  • 28
  • Thank you! yes I saw that question . And I am still trying to implement a server, but it doesnt work properly. Router.run is deprecated... I thought it might be an easier way to do this without writting a server. – Deni Chan Apr 20 '16 at 22:35
-1

Use HashRouter instead of BrowserRouter