0

Ok, I have a project and in the past I made a koa SPA (using koa-static) because I needed it to run the page on heroku, the thing is that now I have react-router in my page and it works half fine. For example using the buttons that I have in the page that have the Link component (aka the component that react router uses to send the user to another route) works fine, and at the same time it changes the url, the thing that doesn't work is when I try to refresh the page/go back(for example if I was on route "/path" and now I am on "/" and I want to go back using the browser buttons it doesnt work)/introduce the url manually in the browser it doesnt work, koa just says Not found and that's because koa doesnt know that those paths are routes in the app rather than actual files/folders.

My question is, how can I make koa work with react router or how can I somehow make react router not change the paths in the url or idk something like that.

vycdev
  • 29
  • 1
  • 6
  • You can use the hash router on the client side, or configure push-state routing on the server side. Both will be covered by the respective docs. – jonrsharpe Apr 26 '20 at 15:13
  • @jonrsharpe Thanks a lot, hash router really helped me, I was trying to solve this problem for so long but I couldn't, thank you. – vycdev Apr 26 '20 at 16:10

0 Answers0