This commit also allows context override, as it is useful for the nested router use case. Closes gh-31831