React-router urls don't work when refreshing or writing manually

前端 未结 30 2719
时光取名叫无心
时光取名叫无心 2020-11-21 05:07

I\'m using React-router and it works fine while I\'m clicking on link buttons, but when I refresh my webpage it does not load what I want.

For instance, I am in

30条回答
  •  执念已碎
    2020-11-21 05:41

    In your index.html head, add the following:

    
    
    

    Then when running with webpack dev server use this command.

    webpack-dev-server --mode development --hot --inline --content-base=dist --history-api-fallback
    

    --history-api-fallback is the important part

提交回复
热议问题