-
Notifications
You must be signed in to change notification settings - Fork 487
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
URL rewrite functionality #149
Comments
I have an implementation here: https://github.com/pavel/live-server/tree/rewrite. I'll create a PR after some testing and feedback gathering. |
@pavel to me this doesn't feel like a very "Node" solution. It just seems way less user friendly than having a function that is called with the URL and can act accordingly. I also can't immediately figure out how I would apply the rewrites I've done using these rules. If you can show me that it might help clear it up. I do think it's a shame though that people will have to be familiar with / learn modrewrite rules in order to benefit from this feature. |
@jackfranklin I'll try to keep it short :)
What I would like to avoid is feelings. Let me expand on this. It might not feel like a "Node" solution due to:
But! It does cover some variety of cases allowing people to get things done. Think of NGINX, it does not provide you a way to specify functions or processing mechanisms for URL rewrite in its config. Though it covers majority of needs using string rules in its config.
If we go with functions, then how do you imagine specifying
I don't quite get your message here. You mean it is not clear what rules to use? Are you confused by rules syntax? Here's a CLI usage example for live-server \
--rewrite="/.+\..+$ - [L]" \
--rewrite="^/(.+)$ /#/\$1 [R,L]"
Don't get me wrong. I don't say that this is a perfect solution. I do understand that this is kind of a tricky thing to figure out. And the complexity of rules is bound to your project's URL handling complexity. And at the point when complexity is too high, you might want to go with your own This SPA rewrite rules I've provided are not generic, they might not work for some projects out there. You'll have to tweak it to your needs, depending on what you consider "assets" and what you consider "SPA URLs". |
@pavel I think we'll have to agree to disagree here ;) My argument really is that rather than use a set of rules that some Node devs may or may not understand (I consider myself good at JS, but I don't know these rules), you could instead allow a custom function to be passed that is called with the URL. I think that's a pattern a lot of modules follow and I would expect more Node devs to be comfortable with that (I may be wrong of course). I would then allow command line usage via a
Which would That's my 2c - but I can see both sides of the argument :) |
@jackfranklin I guess I'm limited on this topic here. |
Just a custom rewrite module people could build that would expected to export a function that will be called to determine if a URL should be rewritten or not. |
URL rewrite functionality is generally useful and commonly used feature so thanks for working on that. As for the spa use case, I wrote my thoughts to #142 (comment) |
We can refactor later if we want to move more stuff to separate files. From the looks of your branch, this functionality is already nicely tidy, mostly just installing a middleware and handling the cli. |
--spa doesn't work, still getting 404s. Also using --mount. |
From #142, #128 and presence of
--spa
option there's a need for URL rewriting mechanism.The text was updated successfully, but these errors were encountered: