Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EES-5820 - rewriting "Location" response headers to replace static webapp FQDN with public FQDN #5599

Merged

Conversation

duncan-at-hiveit
Copy link
Collaborator

This PR:

  • fixes issues where the Public API static webapp's trailing slash redirect were including the static webapp's FQDN in the redirect rather than the public FaUAPI FQDN.

Previously if navigating to a docs URL without a trailing slash, the static webapp (being configured with "trailingSlash": "auto") would redirect to a version of the URL with a trailing slash added. Unfortunately it would implement this as a redirect to an absolute URL with the static webapp's FQDN included.

Thus, navigating to:

https://pp-api.education.gov.uk/statistics-dev/docs/getting-started

would redirect to:

https://witty-bay-020052c03.4.azurestaticapps.net/getting-started/

It doesn't seem like there is any way to override this trailing slash redirect behaviour from the static webapp.

The solution

Looking into this, it was using the HTTP response's "Location" header to instruct the browser to redirect permanently to the https://witty-bay-020052c03.4.azurestaticapps.net/getting-started/ URL.

Seeing as we couldn't configure the webapp to change its behaviour, instead we use Application Gateway to rewrite the response's Location header. We look for Location headers of the form https://witty-bay-020052c03.4.azurestaticapps.net/* and rewrite them to be https://pp-api.education.gov.uk/statistics-dev/docs/* instead.

@duncan-at-hiveit duncan-at-hiveit force-pushed the EES-5820-fix-trailing-slash-redirects-in-static-webapp branch from dbe9653 to 41454ae Compare February 12, 2025 14:57
@duncan-at-hiveit duncan-at-hiveit merged commit 3eb83d3 into dev Feb 17, 2025
10 checks passed
@duncan-at-hiveit duncan-at-hiveit deleted the EES-5820-fix-trailing-slash-redirects-in-static-webapp branch February 17, 2025 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants