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 have an end point at /v1/report using express-jwt to enforce authorization. That end point takes params like this:

router.get('/:type/:email/:date?/', function ...

however, adding the urls to unless after it won’t work for that end point. It does work for the other two. My feeling is that it seems to believe that the parameters are, in fact, part of the end point rather than parameters. Is this the case?

app.use(expressJwt({ secret: config.SECRET })
    .unless({ path: [ '/v1/auth', '/v1/is-alive', '/v1/report' ] }));

I’m sure this is just a lack of understanding on my part of the unless implementation, but I’m hoping you can assist in figuring out a way to allow for it.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
zeg-iocommented, Jun 15, 2016

@alexpchin Just so you have an answer for you… the solution is as so:

.unless({
        path: [
            /\/v1\/data\/devices-.*\.xml/
        ] });

This checks for /v1/data/devices-[something].xml

Notice there are NOT quotes around the regex but /…/

3reactions
zeg-iocommented, Jun 15, 2016

After further review and digging around I found that regular expressions can be used, which accomplishes what I needed. Given that having parameters in the path is pretty common I’d suggest making the documentation more obvious and up front as currently the main README.md doesn’t list that possibility at all.

Love .unless though 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are URL parameters? | Learn SEO - Botify
URL parameters (also known as “query strings”) are a way to structure additional information for a given URL. Parameters are added to the...
Read more >
A Beginner's Guide to URL Parameters - SEMrush
URL parameters (known also as “query strings” or “URL query parameters”) are elements inserted in your URLs to help you filter and organize ......
Read more >
URL Parameters: A Complete Guide for SEOs - Ahrefs
URL parameters or query strings are the part of a URL that typically comes after a question mark (?) and are used to...
Read more >
About URL parameters - Google Ads Help
URL parameter is a way to pass information about a click through its URL. You can insert URL parameters into your URLs so...
Read more >
Query string - Wikipedia
A query string is a part of a uniform resource locator (URL) that assigns values to specified parameters. A query string commonly includes...
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