I am using historyApiFallback: true
to redirect all non-existing urls to index page. It is working fine for 1st level route, say localhost:8080/abc . But when I try localhost:8080/abc/xyz , I get error in browser console which says
http://localhost:8080/abc/scripts/bundle.js 404 (Not Found)
Webpack config is
const path = require('path');
module.exports = {
entry:"./src/app.js",
output:{
path:path.join(__dirname,'public','scripts'),
filename:'bundle.js'
},
module:{
rules:[{
test:/\.js$/,
exclude:/node_modules/,
loader:'babel-loader'
}]
},
devServer:{
contentBase:path.join(__dirname,'public'),
publicPath:'/scripts/',
historyApiFallback: true
}
}
Index page
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="app">
hello
</div>
</body>
<script type="text/javascript" src="scripts/bundle.js"></script>
</html>
Folder structure is
-node_modules/
-public/
-scripts/
-index.html
-src/
-app.js
-package.json
-webpack.config.js
What am I missing?