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

Add ability to specify paths to ignore #22

Closed
wants to merge 4 commits into from

Conversation

randyaa
Copy link

@randyaa randyaa commented Apr 2, 2016

Thanks for the great library!

We're using this on an angular2 project right now embedded within a gulp script for our local serve task and it's working great. The one downside is that any requests to local resources that fail get redirected to the index page which often times results in a strange error having something to do with an unexpected < character.

This pull request adds the ability to configure some url patterns that if they exist in the URL being requested, the redirect to index does not happen.

The way it's implemented could result in not redirecting to index when you really wanted to but as it's opt-in via a configuration (The readme has been updated to reflect the new configuration item) I thought leaving it as wide open and configurable by the end user as possible would be a good thing.

Thoughts?

Thanks,
Randy

@bripkens
Copy link
Owner

bripkens commented Apr 2, 2016

Thanks for the PR! Before accepting this, I would like to understand why the existing rules do not cover your use case. This middleware is nowadays used by a larger number of users whose requirements probably aren't very different to yours. Specifically:

The one downside is that any requests to local resources that fail get redirected to the index page which often times results in a strange error having something to do with an unexpected < character.

Why do these requests fail? I'd assume that these resources aren't redirected due to the rule:

is not a direct file request, i.e. the requested path does not contain a . (DOT) character

@randyaa
Copy link
Author

randyaa commented Apr 2, 2016

One way to reproduce the problem is to run an app utilizing SystemJS without the proper mapping provided in the system config.

our project's system-config looks very similar to the one found here. Provided that app is running with the connect-history-api-fallback middleware, removing any one of the material2 dependencies from that block results in an error message when rendering the page that looks like: Error: SyntaxError: Unexpected token <(…) which as you can see contains no information helpful with troubleshooting. This happens because the request looks like <app-base-url>/lib/@angular2-material/button and SystemJS should take care of translating that to the reference to the javascript file but in this case it doesn't because it's the SystemJS mapping that's missing. Instead we end up fetching the index page due to the rerouting rule in connect-history-api-fallback which then causes the parser to interpret the index page as javascript & then fails on the starting < in the html of the index page.

@bripkens
Copy link
Owner

Closing due to inactivity.

@bripkens bripkens closed this Aug 29, 2016
@cryptiklemur
Copy link

cryptiklemur commented Aug 19, 2017

This would be handy for me, as i have a mix of routes that have Server Rendering, and a few that dont. I have no way to get route parameters in express right now for routes that i dont want rewritten.

Why not check to see if theres an existing route, and use that, instead of re-writing

@smholsen
Copy link

smholsen commented Mar 6, 2019

I would also like to +1 this.
Say for example if you need to do email verification. Then it would be very handy to allow a url e.g. example.com/verify?token=abc to fall through to the api server.

@bripkens
Copy link
Owner

I just added a new sample app that explains how to do based on arbitrary HTTP parameters. Hope this resolve this for you folks.

https://github.com/bripkens/connect-history-api-fallback/tree/master/examples/ignore-rules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants