I am trying to configure the Angular router to match any path that starts with a specific prefix and route it to a component. Below is my current router setup:
{
path: 'posts/:id/:title',
component: PostDetailsComponent
}
Everything works fine when I navigate to a route like
/posts/1/json-web-token-(jwt)-authentication-with-asp.net-core-2.0
using router.navigate()
, but I encounter an error when I try to refresh the page:
Cannot match any routes. URL Segment: 'jwt'
Error: Cannot match any routes. URL Segment: 'jwt'
at ApplyRedirects.noMatchError (router.js:1719)
I have explored a solution suggested here, but it did not work for my specific case. I also attempted to modify my router configuration to:
{
path: 'posts/:id/**',
component: PostDetailsComponent
}
However, this resulted in an error during the build process. Is there a way to successfully match any route that starts with /posts/:id/
?