Как правильно настроить роуты на сервере?

Сделал маршруты с помощью react-router-dom. На локальном сервере всё работает отлично, но когда я поместил проект на хостинг маршруты работают, но после обновления страницы я вижу ошибку 404. Подскажите как настроить маршруты на сервере чтобы они работали. Проект у меня на React-Redux. Спасибо большое!

Routes

    <Switch>
        <Route exact path='/' component={Home} />
        <Route path='/firstPage' component={FirstPage} />
        <Route path='/secondPage' component={SecondPage} />
        <Route path='/thirdPage' component={ThirdPage} />
    </Switch>

webpack.config

const path = require('path');
const HtmlWebpackPlugin = require("html-webpack-plugin");


let conf = {
    entry: './src/index.js',
    output: {
        path: path.join(__dirname, "/dist"),
        filename: 'main.js'
    },
    devServer: {
        overlay: true,
        historyApiFallback: true,
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env','@babel/preset-react'],
                        plugins: [
                            "@babel/plugin-transform-react-jsx",
                            "@babel/plugin-proposal-class-properties"
                        ]
                    }
                }
            },
            {
                test: /\.scss$/,
                use: ['style-loader','css-loader','sass-loader']
            },
            {
                test: /\.(jpe?g|png|gif|svg|mov|mp4)$/i,
                use: 'file-loader'
            },
            { 
                test: /\.(woff|woff2|eot|ttf|svg)$/,
                loader: 'url-loader?limit=100000' 
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
          template: "./src/index.html"
        })
      ]

};

module.exports = (env, options) => {
    conf.devtool = options.mode === "production" ?
        false :
        "cheap-module-eval-source-map";
    return conf;
};

Ответы (0 шт):