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

前端 未结 30 2727
时光取名叫无心
时光取名叫无心 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:52

    Fixing the "cannot GET /URL" error on refresh or on calling the URL directly.

    Configure your webpack.config.js to expect the given link the routes like this.

    module.exports = {
      entry: './app/index.js',
      output: {
           path: path.join(__dirname, '/bundle'),
           filename: 'index_bundle.js',
           publicPath: '/'
      },
    

提交回复
热议问题