Skip to content
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

Catch-all Routes can't be passed as input #1016

Open
1 of 2 tasks
alexcibotari opened this issue Apr 8, 2024 · 4 comments
Open
1 of 2 tasks

Catch-all Routes can't be passed as input #1016

alexcibotari opened this issue Apr 8, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@alexcibotari
Copy link

alexcibotari commented Apr 8, 2024

Please provide the environment you discovered this bug in.

https://stackblitz.com/edit/github-wjglg2?file=src%2Fapp%2Fpages%2F%5B...product%5D.page.ts

Which area/package is the issue in?

router

Description

I consume a Headless CMS Localess: https://github.com/Lessify/localess
For that, I created one route that would capture all routes and fetch data via API using the feature: Using Route Component Input Bindings
For the moment the feature works only for dynamic routes, which limits me only to a one-page level, where I actually would like to be able to capture all possible routes.

Dynamic Rout will work with the next

/coffee
/milk
/sugar

But it will not be able to handle next

/coffee/sugar/line
/milk/cow/grass
/en/free/products
/en/company/contact

Please provide the exception or error you saw

No response

Other information

Same time ActivatedRouteSnapshot.params is empty

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@alexcibotari alexcibotari added the bug Something isn't working label Apr 8, 2024
@brandonroberts
Copy link
Member

brandonroberts commented Apr 8, 2024

You won't be able to use the router input bindings here because a catch-all route isn't captured as a route parameter. You can use the router.url to get the full URL path that was used.

https://stackblitz.com/edit/github-wjglg2-5fczvg?file=src%2Fapp%2Fpages%2F[...product].page.ts

@alexcibotari
Copy link
Author

alexcibotari commented Apr 8, 2024

@brandonroberts , thank you for the explanation. I think the documentation needs to be updated to make sure others are not making the same mistakes. and I can create one example of integration with Localess Headless CMS.

@alexcibotari
Copy link
Author

I found another issue when I had only one page with catch-all pages and Server-Side Data Fetching for that page. I'm receiving a next error. I have updated the example also

ERROR HttpErrorResponse {
  headers: HttpHeaders {
    normalizedNames: Map(4) {
      'connection' => 'connection',
      'content-length' => 'content-length',
      'content-type' => 'content-type',
      'date' => 'date'
    },
    lazyUpdate: null,
    headers: Map(4) {
      'connection' => [Array],
      'content-length' => [Array],
      'content-type' => [Array],
      'date' => [Array]
    }
  },
  status: 404,
  statusText: 'Cannot find any route matching /_analog/pages/.',
  url: 'http://localhost:5173/api/_analog/pages/',
  ok: false,
  name: 'HttpErrorResponse',
  message: 'Http failure response for http://localhost:5173/api/_analog/pages/: 404 Cannot find any route matching /_analog/pages/.',
  error: {
    url: '/_analog/pages/',
    statusCode: 404,
    statusMessage: 'Cannot find any route matching /_analog/pages/.',
    message: 'Cannot find any route matching /_analog/pages/.'
  }
}

@brandonroberts
Copy link
Member

@alexcibotari was this on StackBlitz or locally? The full server environment is not enabled on StackBlitz yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants