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.

Wildcards don't work anymore in v5

See original GitHub issue

Hi, I’m using express to serve an Angular app. This has a few files which need to be served statically (index.html, some css, js and images) and then has its own routing which means that all other URLs need to serve the index.html.

In Express 4 I was able to do this:

app.use("/", express.static("/app/dist/frontend", {dotfiles: "allow"}));
app.use("*", express.static("/app/dist/frontend/index.html", {dotfiles: "allow"}));

However, in Express 5 it always returns 404 for /myCustomRoute… Here are the logs (debug=*):

  body-parser:json skip empty body +13s
  send stat "A:\app\dist\frontend\myCustomRoute" +13s
  finalhandler default 404 +2ms

It doesn’t help to set fallthrough: true

I’d really like to contribute a fix if you can point me in the right direction. We really need Express 5 because of its improved error handling with promises.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
hruegercommented, Feb 28, 2022

I think that’s the same problem as you had in the first post, but now in the router?

🤦‍♂️Of course, sorry for that.

router.use((req, res) => res.sendStatus(404).end());

works.

Thanks for your efforts!

0reactions
LinusUcommented, Feb 28, 2022

#4833 is also vaguely related. I realise that you could also do .use('/', ...) which should be the same as * used to be

Read more comments on GitHub >

github_iconTop Results From Across the Web

The asterisk (*) wildcard no longer works when defining URLs ...
Issue 371888 : The asterisk (*) wildcard no longer works when defining URLs for whitelisting (using the Windows Group Policy Editor and chrome....
Read more >
linux wildcard usage in cp and mv - Stack Overflow
Let's talk about how wildcards work for a minute. cp *.txt foo. doesn't actually invoke cp with an argument *.txt , if any...
Read more >
Find and Replace with wildcards not working after Office update.
I have just updated my Office Software. Find and replace using wildcards no longer works. I want, for example, to delete everything between ......
Read more >
JQL - Add wildcard functionality to versions
I was very disappointed to find out wild cards don't work for fix versions. ... in v3.0.1 of the plugin so that means...
Read more >
Frequently Asked Questions - Snakemake - Read the Docs
I don't want expand to use every wildcard, what can I do? Snakemake complains about a cyclic dependency or a PeriodicWildcardError. What can...
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