shakyShane / browser-sync-spa

Better Single Page App support for BrowserSync
29 stars 15 forks source link

Links that include a dot are routed incorrectly #5

Open brianchaan opened 9 years ago

brianchaan commented 9 years ago

I've been debugging this problem for a while now and I am reasonably sure that it stems from this library, but please correct me if I'm wrong.

I'm using browser-sync and browser-sync-spa with gulp, generated from the yeoman gulp-angular generator. If I try to serve a url with a dot in it, the server seems to be confused and tries to route it away from my code. I'm guessing it is trying to serve a physical file, but the dot is just part of my angular route.

My particular problem is that I have a route for user activation that includes an email address:

localhost:3001/activate/key/user@domain.com

Is there any way to tell the server that this is part of the route and not an actual file?

at0g commented 8 years ago

I believe this is due to the default behaviour of connect-history-api-fallback which is used internally in browser-sync-spa to serve fallback pages.

Take a look at the rewrite option (particularly the jquery example) - presumably you could match your email address route with a rewrite rule to return the default html page.

brianchaan commented 8 years ago

Looks like that would probably work. I ended up changing my route to use query parameters instead:

/activate?key=key&email=user@domain.com