Repository navigation
SSR url normalization causes 302 redirects #31881
Description
Activity
- added 2 commits that reference this issue
on Nov 20, 2025 - addedfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarely
on 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
Reacted by Tim Geerlings and Rico- added 3 commits that reference this issue
on Nov 20, 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.
- added a commit that references this issue
on Nov 21, 2025 - added a commit that references this issue
on Nov 21, 2025 Yes. this will be backported to version 20.
Reacted by Marco Glauser- added a commit that references this issue
on Nov 21, 2025 - linked a pull request that will close this issueCherry-pick several SSR/SSG fixes to 20.3.x #31910
on Nov 21, 2025 - added a commit that references this issue
on Nov 21, 2025 angular-automatic-lock-bot commented
on Dec 22, 2025 More actionsThis 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.
- locked and limited conversation to collaborators
on Dec 22, 2025
Command
serve
Is this a regression?
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
Exception or Error
Your Environment
Anything else relevant?
No response