Skip to content

Commit 20fb3ae

Browse files
authored
Fix HistoryApiFallback when publicPath is set
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 #216
1 parent 2f02d0c commit 20fb3ae

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/Server.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ function Server(compiler, options) {
189189
historyApiFallback: function() {
190190
if(options.historyApiFallback) {
191191
// Fall back to /index.html if nothing else matches.
192-
app.use(historyApiFallback(typeof options.historyApiFallback === 'object' ? options.historyApiFallback : null));
192+
var historyApiFallbackOptions = typeof options.historyApiFallback === 'object' ? options.historyApiFallback : {};
193+
// If publicPath is set then fallback to publicPath (where there would be index.html)
194+
if (!historyApiFallbackOptions.index && options.publicPath) historyApiFallbackOptions.index = options.publicPath;
195+
app.use(historyApiFallback(historyApiFallbackOptions));
193196
}
194197
},
195198

0 commit comments

Comments
 (0)