Когда в урл вбивается /people/1 выходит ошибка:
GET http://localhost:8080/people/main.bundle.js net::ERR_ABORTED 404 (Not Found)
Это код из App.js:
import React from 'react';
import { Redirect, Route, Switch } from 'react-router';
import './App.scss';
import Content from './components/Content/Content.jsx';
const App = () => {
return (
<Switch>
<Route path='/people/:personId?' render={() => <Content />} />
<Route path='/planets/:planetId?' render={() => <Content />} />
<Route path='/starships/:starshipId?' render={() => <Content />} />
<Route path='/' render={() => <Redirect to='/people' />} />
<Route path='*' render={() => <Redirect to='/people' />} />
</Switch>
);
};
export default App;
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.1/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.1/umd/react-dom.production.min.js"></script>
Это мой webpack.config.js:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const webpack = require('webpack');
module.exports = {
mode: 'development',
devServer: {
historyApiFallback: true,
static: {
directory: path.join(__dirname, './dist'),
},
contentBase: path.resolve(__dirname, './dist'),
open: true,
compress: true,
hot: true,
port: 8080,
},
entry: ['regenerator-runtime/runtime.js', './src/index.js'],
output: {
path: path.resolve(__dirname, './dist'),
filename: 'bundle.js',
publicPath: '/'
},
plugins: [
new HtmlWebpackPlugin({
title: 'webpack Boilerplate',
template: path.resolve(__dirname, './src/index.html'),
filename: 'index.html'
}),
new CleanWebpackPlugin(),
new webpack.HotModuleReplacementPlugin(),
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
},
},
{
test: /\.(?:ico|gif|png|jpg|jpeg)$/i,
type: 'asset/resource',
},
{
test: /\.(woff(2)?|eot|ttf|otf|svg|)$/,
type: 'asset/inline',
},
{
test: /\.(scss|css)$/,
use: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader'],
},
],
}
};