You need to adapt your code to something like this:
router.get('*', (req, res) => { ... });
In Express v5, *
is used to match all routes, including the ones without a preceding /
As before, make sure the wildcard rout is defined last in the route definitions to avoid it overriding more specific routes.