From 3007d00e71d0233fde6d0bb01a378bdd5936587d Mon Sep 17 00:00:00 2001 From: Megh Parikh Date: Thu, 30 Jun 2016 23:35:50 +0530 Subject: [PATCH] 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 --- lib/Server.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Server.js b/lib/Server.js index f2ca75a7ff..19b8568320 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -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)); } },