You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using 5.0.1 and I cannot get the .all('(.*)') to work. I have followed all the examples. Dropping down to 4.x as this has drained a lot of time.
Code:
this.expressApp.all('(.*)', function (req, res, next) {
res.set('X-Powered', 'XXX');
next();
});
Error:
D:\service.profile\api\node_modules\path-to-regexp\dist\index.js:123
throw new TypeError(`Unexpected ${nextType} at ${index}, expected ${type}: ${DEBUG_URL}`);
^
TypeError: Unexpected ( at 1, expected END: https://git.new/pathToRegexpError
at Iter.consume (D:\service.profile\api\node_modules\path-to-regexp\dist\index.js:123:15)
at consume (D:\service.profile\api\node_modules\path-to-regexp\dist\index.js:179:16)
at parse (D:\service.profile\api\node_modules\path-to-regexp\dist\index.js:183:20)
at D:\service.profile\api\node_modules\path-to-regexp\dist\index.js:294:74
at Array.map (<anonymous>)
at pathToRegexp (D:\service.profile\api\node_modules\path-to-regexp\dist\index.js:294:25)
at Object.match (D:\service.profile\api\node_modules\path-to-regexp\dist\index.js:264:30)
at matcher (D:\service.profile\api\node_modules\router\lib\layer.js:83:23)
at new Layer (D:\service.profile\api\node_modules\router\lib\layer.js:90:62)
at Function.route (D:\service.profile\api\node_modules\router\index.js:421:17)
Node.js v18.14.0
The text was updated successfully, but these errors were encountered:
Express 5 does not allow regular expression strings as path. '(.*)' worked in the 5.0.0-beta versions as a replacement for 4.x (*), but since 5.0.0, something like {*paramName} must be used (see #6111 (comment) and the migration guide).
In this use case, it would probably be simpler to just use .use((req, res, next) => { /*...*/ }), if you want the function to be called for all paths.
I did look at the migration guide, but that was for specific paths, not for everything. But your @krzysdz your example there is precisely what I was looking for. THANK YOU.
Using 5.0.1 and I cannot get the .all('(.*)') to work. I have followed all the examples. Dropping down to 4.x as this has drained a lot of time.
Code:
Error:
The text was updated successfully, but these errors were encountered: