diff --git a/src/jspm-hmr-server.ts b/src/jspm-hmr-server.ts index d7022f7..2b616b9 100644 --- a/src/jspm-hmr-server.ts +++ b/src/jspm-hmr-server.ts @@ -47,17 +47,6 @@ export function createServer(options: ServerOptions): JspmHmrServer { // 'Access-Control-Allow-Credentials': 'true', // }; - // Apply routing rewrites to serve /index.html for SPA Applications - - if (options.fallback) { - const fallback = options.fallback === true ? '/index.html' : options.fallback; - console.log('history api fallback active', fallback); - - app.use(historyApiFallback({ - index: fallback, verbose: !!options.verbose, - })); - } - // Proxy if (options.proxy) { const proxyTarget = options.proxy; @@ -73,6 +62,18 @@ export function createServer(options: ServerOptions): JspmHmrServer { }); } + // Apply routing rewrites to serve /index.html for SPA Applications + + if (options.fallback) { + const fallback = options.fallback === true ? '/index.html' : options.fallback; + console.log('history api fallback active', fallback); + + app.use(historyApiFallback({ + index: fallback, verbose: !!options.verbose, + })); + } + + // Static files & Cache const staticRoot = options.path || '.'; const cache = options.cache && options.cache * 1000 || -1; diff --git a/test/jspm-hmr-server.spec.ts b/test/jspm-hmr-server.spec.ts index 5eda8df..df8ef65 100644 --- a/test/jspm-hmr-server.spec.ts +++ b/test/jspm-hmr-server.spec.ts @@ -107,7 +107,11 @@ describe('testing jspmHmrServer features', () => { done(); }).listen(TARGET_PORT); - http.request(`${SERVER_ADDRESS}/api/search?param=value`).end(); + http.request({ + port: SERVER_PORT, + path: '/api/search?param=value', + headers: {'accept': '*/*'} + }).end(); }); });