Skip to content

Commit

Permalink
Fix HistoryApiFallback when publicPath is set
Browse files Browse the repository at this point in the history
Currently HistoryApiFallback does not work properly when publicPath as it redirects request to /index.html which gives as it does not exist, instead we should redirect to publicPath (which redirects to publicPath/index.html).

Fixes webpack#216
  • Loading branch information
meghprkh committed Jun 30, 2016
1 parent 2f02d0c commit 20fb3ae
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Server.js
Expand Up @@ -189,7 +189,10 @@ function Server(compiler, options) {
historyApiFallback: function() {
if(options.historyApiFallback) {
// Fall back to /index.html if nothing else matches.
app.use(historyApiFallback(typeof options.historyApiFallback === 'object' ? options.historyApiFallback : null));
var historyApiFallbackOptions = typeof options.historyApiFallback === 'object' ? options.historyApiFallback : {};
// If publicPath is set then fallback to publicPath (where there would be index.html)
if (!historyApiFallbackOptions.index && options.publicPath) historyApiFallbackOptions.index = options.publicPath;
app.use(historyApiFallback(historyApiFallbackOptions));
}
},

Expand Down

0 comments on commit 20fb3ae

Please sign in to comment.