-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
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
Using /*splat in app.all() does not work on v5 #6111
Comments
It definitely should work. What exactly doesn't work in your case? Is the handler skipped or do you get an error? This simplified code works as expected: const express = require("express");
const app = express();
app.all("/api/*sth", (req, res, next) => {
res.setHeader("my-header", "a value");
next()
});
app.get("/*p", (req, res) => res.send("ok"));
const server = app.listen(1234, () =>
fetch("http://localhost:1234/api/random/path").then(r => {
console.log(r.headers);
server.close();
})
); |
In this case it may be easier to use app.use("/api", (req, res, next) => {
// set headers
next();
});
|
Hi @krzysdz 👋 I think I'm also encountering a similar problem. If I have a route on So for example, the file
Logs After migrating to [email protected] the file looks like:
Which logs |
Good catch @Tate-CC ! I did not notice it, but the
Looks like an optional group |
Hi,
I recently tried to upgrade to v5 from v4 and used the following guide:
https://expressjs.com/en/guide/migrating-5.html#path-syntax
Here is my
app.all()
that sets headers on all routes:As per documentation:
I changed it to:
This does not work. Anything I am doing wrong?
The text was updated successfully, but these errors were encountered: