More robust resolving of Delivery API redirects #18160
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
If there's an existing issue for this PR then this fixes #16901
Description
As described in the linked issue, URL redirects can fail to resolve under certain conditions.
The culprit is how URL redirects are tracked - and how it changes over time, depending on content configuration:
1234/original/path
The magic "root ID prefix" seems generally to be applied when there are domains configured. Since redirects can be created both before and after domain configurations, we potentially have to look for both permutations when resolving redirect URLs for the Delivery API.
This PR updates the logic to be as follows:
Testing this PR
First and foremost you'll likely need to use Postman to test this, and make sure that it's setup to not follow redirects automatically.
Test redirects for content structures
The logic outlined above should provide test cases.
To explicitly verify that this PR fixes the linked issue
Create a content setup with:
Request one of the children by path from the Delivery API using localhost and its corresponding start-item header.
Rename the child and re-publish it. This should result in a tracked redirect URL.
Request the child by path from the Delivery API again. The Delivery API should respond with an appropriate redirect.