'*' wildcard
See original GitHub issueI can’t seem to find this in the docs, but is it possible to route with a ‘*’ wildcard that acts as a middleware?
Example:
const routes = mount({
'/login': route({
view: <div>Login</div>,
}),
'/': redirect('/login'),
'*': map((req, { user }) => (user ? protectedRoutes : redirect(req.originalUrl))),
});
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Examples of wildcard characters - Microsoft Support
Wildcards are special characters that can stand in for unknown characters in a text value and are handy for locating multiple items with...
Read more >wildcard - Wiktionary
(computing) A character that takes the place of any other character or string that is not known or specified. · (also written wild...
Read more >Studio Wildcard
ARK II. ARK II thrusts players into a brutal new world of primitive survival against both beast and man, facing down the ever-present...
Read more >Wildcard: Shop Pittsburgh's Best Gifts
Wildcard has been providing the area with unique cards, t-shirts, gifts, baby & kids' gifts, original art prints and much more since 2009....
Read more >Wild card Definition & Meaning - Merriam-Webster
The meaning of WILD CARD is an unknown or unpredictable factor. How to use wild card in a sentence.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The way I currently do this is to just protect routes one at a time; so instead of wrapping a
mount()
with amap()
that redirects when unauthenticated, I wrap individual routes. I go into the details in this guide.You could even create a custom
withAuthentication()
matcher that can be composed together, if that simplifies things.I’m currently putting together an example using firebase for auth, and hope to have it done this weekend. That would probably be the best way for me to demonstrate.
I’ve been thinking about this and I think it should still be possible by using custom headers or a custom HTTP method. E.g. use
get
to see if there is a page at the URL, and usemap
to find a list of URLs at the URL. In the meantime it’d be easier to just avoid the issue, though.Have just pushed wildcard support, will be part of the next release.