On demand rendering with query parameters does not match route
rafinskipg opened this issue · 4 comments
Hi!
Using the on demand render with express we are experiencing 404 errors because the application is not being able to process query parameters of a url.
If we remove the query parameters the application is being able to render the correct page application.renderUri(uri)
, but with query parameters not.
We have removed the query parameters but we know this is an undesired behaviour that can led to unexpected renderings.
I've worked it around by encodeURIComponent'ing urls at server and decoding them back at Angular's NavigationStart event.
Have you checked the value of the URI passed into renderUri
on the server side?
I had this problem with code from the Express example. I used that as a starting point for my app, and found that its absoluteUri
function was messing up the query params.
Using query parameters with server-side rendering really isn't a good idea... there's nothing in angular-ssr
that prevents you from using them but if you are just copy-pasting the example code, it will strip query parameters. You should not just assume that the code from the example is exactly perfect for your particular scenario. You should try to understand what it is doing. If you want to use query strings, you can do that, and when it renders the application it will take query string parameters into account, but they must be passed into renderUri
.
As @lugkhast noted, you need to modify the request handler code so that it includes query strings. But I would counsel against using query strings in the first place. Better to use proper URLs like the example app does /blog/1321
(where 1321
is an ID)
@clbond there are certain implementations like using query parameters for pagination in some lists, it is not all about good looking urls but certain business logic implementations that need to be considered. But thank you, i will take a look at the request handler and see if i can manage to change it.
Peace