question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I 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:closed
  • Created 5 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jamesknelsoncommented, Mar 2, 2019

The way I currently do this is to just protect routes one at a time; so instead of wrapping a mount() with a map() 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.

it’s going to be tricky to build a site map

Nearly impossible right? Haha.

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 use map to find a list of URLs at the URL. In the meantime it’d be easier to just avoid the issue, though.

0reactions
jamesknelsoncommented, Mar 17, 2019

Have just pushed wildcard support, will be part of the next release.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found