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
Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
With the introduction of #31497, we noticed higher CPU usage and looked at the logs. We noticed a lot of 302 redirects happening now that will cause 2 requests to be served instead of one.
Angular SSR is already slow, taking more than a second to answer requests. With the introduction of the redirects, the ssr server now has to compute two requests and end user latency doubles.
It looks like the internal url normalization of angular will issue redirects, where they're not necessary.
Minimal Reproduction
This url
/?email=xyz%40xyz.com
Will redirect to
/?email=xyz@xyz
Our application runs pages with a trailing slash, we have configured a redirect in our SSR server when a url without trailing slash is requested. As of v20.3.x we see a recursive redirect. This is caused by a change in renderAngular where redirectTo determination now uses stripTrailingSlash.
Previously the url was not manipulated (const finalUrlStringified = finalUrl.toString();) but since 20.3.x this url has the trailing slash stripped (const finalUrl = [stripTrailingSlash(pathname), search, hash].join('');) without a means to configure it. The effect is that a 302 is given to the browser with a Location header where the trailing slash is stripped. Locally removing the stripTrailingSlash usage resolves the issue.
It would be best if the stripping of trailing slash could be configured, though at the moment I would not know how this could best be achieved
Thank you @alan-agius4 for providing a quick fix :) Is there any chance this patch will be backported to v20?
We can't upgrade to v21 yet because other libraries are not compatible yet.
For now, we're side stepping this issue by configuring our reverse proxy to strip all url params and handle the trailing slash redirects directly instead of proxying the request.
Activity
fix(@angular/ssr): prevent redirect loop with encoded query parameters
fix(@angular/ssr): prevent redirect loop with encoded query parameters
stevengunneweg commentedon Nov 20, 2025
We experienced an issue with the same cause.
Our application runs pages with a trailing slash, we have configured a redirect in our SSR server when a url without trailing slash is requested. As of v20.3.x we see a recursive redirect. This is caused by a change in
renderAngularwhereredirectTodetermination now usesstripTrailingSlash.Previously the url was not manipulated (
const finalUrlStringified = finalUrl.toString();) but since 20.3.x this url has the trailing slash stripped (const finalUrl = [stripTrailingSlash(pathname), search, hash].join('');) without a means to configure it. The effect is that a 302 is given to the browser with aLocationheader where the trailing slash is stripped. Locally removing thestripTrailingSlashusage resolves the issue.It would be best if the stripping of trailing slash could be configured, though at the moment I would not know how this could best be achieved
fix(@angular/ssr): prevent redirect loop with encoded query parameters
fix(@angular/ssr): prevent redirect loop with encoded query parameters
fix(@angular/ssr): prevent redirect loop with encoded query parameters
MarcoGlauser commentedon Nov 21, 2025
Thank you @alan-agius4 for providing a quick fix :) Is there any chance this patch will be backported to v20?
We can't upgrade to v21 yet because other libraries are not compatible yet.
For now, we're side stepping this issue by configuring our reverse proxy to strip all url params and handle the trailing slash redirects directly instead of proxying the request.
fix(@angular/ssr): prevent redirect loop with encoded query parameters
fix(@angular/ssr): prevent redirect loop with encoded query parameters
alan-agius4 commentedon Nov 21, 2025
Yes. this will be backported to version 20.
fix(@angular/ssr): prevent redirect loop with encoded query parameters
fix(@angular/ssr): prevent redirect loop with encoded query parameters
angular-automatic-lock-bot commentedon Dec 22, 2025
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.