Migrate from express 4 to 5 #6210
Replies: 2 comments 1 reply
-
```js
app.options('/*paramName', /* handler */); // All routes, except /
app.options('/{*paramName}', /* handler */); // All routes including /
```
You can replace `paramName` with anything as long as it is a valid JS identifier.
See:
- https://git.new/pathToRegexpError (yes, that's the link from the error message)
- #5936
- #6111
- [5.x migration guide](https://expressjs.com/en/guide/migrating-5.html)
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
bjohansebas
-
So now you need to be more explicit - where as the '*' was more like a wildcard matching everyting - right? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How du you migrate this when switchen from express 4 to 5:
app.use(cors());
app.options('*', cors()); // include before other routes
It gives a
/xxx/node_modules/path-to-regexp/dist/index.js:73 throw new TypeError(
Missing parameter name at ${i}: ${DEBUG_URL}); ^ TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError
Beta Was this translation helpful? Give feedback.
All reactions