Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give proxy precedence over history api fallback #16

Merged
merged 3 commits into from
Mar 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/jspm-hmr-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion test/jspm-hmr-server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});

Expand Down