Ich habe eine Single-Page-App, die die History-API verwendet. Also habe ich historyApiFallback:true
in meiner config-Datei, aber ich bekomme immer noch 404
für jede unbekannte Dateiwebpack historyApiFallback funktioniert nicht?
Befehlszeile: webpack-dev-server --config webpack.config.js --hot --inline --progress --devtool eval
Config-Datei:
module.exports = {
devServer: {
host: 'localhost',
port: 3000,
historyApiFallback: true
},
entry: {
main: [
'./src/main'
]
},
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js'
},
module: {
loaders: [
{ test: /\.js$/, loader: 'babel', exclude: /node_modules/, query: { presets: ['es2015-loose', 'stage-1'], plugins: ['transform-decorators-legacy'] } },
{ test: /\.css?$/, loader: 'style!css' },
{ test: /\.html$/, loader: 'html' },
{ test: /\.(png|gif|jpg)$/, loader: 'url?limit=8192' },
{ test: /\.woff2(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url?limit=10000&minetype=application/font-woff2' },
{ test: /\.woff(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url?limit=10000&minetype=application/font-woff' },
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file' }
]
}
};
Es baut ganz gut, aber wenn ich versuche, eine Datei zu erhalten, die bekomme ich nur ein 404
eher nicht vorhanden ist, als meine index.html
:
$ curl -i localhost:3000/asbasas
HTTP/1.1 404 Not Found
X-Powered-By: Express
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=utf-8
Content-Length: 20
Date: Thu, 24 Mar 2016 18:27:33 GMT
Connection: keep-alive
Cannot GET /asbasas
Webpack Version:
$ webpack-dev-server --help
webpack-dev-server 1.14.1
Also ... was mache ich falsch?
UPDATE:
ich tun, um eine Nachricht beim Start, dass
404s will fallback to /index.html
Aber trotzdem ...