readthedocs.org
readthedocs.org copied to clipboard
Forced redirect `/$rest -> example.com` redirects PR previews (external domain) to target domain
Details
- Read the Docs project URL: https://readthedocs.org/projects/xray/
- Build URL (if applicable): https://readthedocs.org/projects/xray/builds/18134887/
- Read the Docs username (if applicable): https://readthedocs.org/profiles/{your_rtd_username}/
Expected Result
Pull Request preview to work when using custom domain.
Actual Result
We recently switched to using a custom domain for our docs on RTD docs.xarray.dev, and this appears to have broken the pull request preview feature (or this doesn't seem to work for us at least). For instance, The GitHub check for this PR: https://github.com/pydata/xarray/pull/7061 points to https://docs.xarray.dev/en/7061/. This page returns a 404
Cc @jhamman
Hi, this looks like a side effect of the exact redirect that the project has in place.
/$rest -> https://docs.xarray.dev/
.
That redirect will redirect all requests to the docs.xarray.dev domain, but in this case it should stay in https://xray--7061.org.readthedocs.build/en/7061/, which is the domain for serving PR previews.
One way to solve this would be to create that redirect only for the active versions on https://readthedocs.org/projects/xray/versions/, i.e /latest/$rest -> https://docs.xarray.dev/latest/
, /stable/$rest -> https://docs.xarray.dev/stable/
, and so on.
Another way would be for us to support matching the domain in the redirect, this is
https:///xarray.readthedocs.io/$rest -> https://docs.xarray.dev/
(it will only redirect for requests on the readthedocs.io domain).
And other solution could be to ignore user redirects when serving PR previews.
https://xarray.readthedocs.io/$rest -> https://docs.xarray.dev/ (it will only redirect for requests on the readthedocs.io domain).
this solution appears to be working for us 🎉 . Thank you, @stsewd!
Actually, I'm not sure it is working.
https://xarray.pydata.org/en/stable/api.html is no longer redirecting to https://docs.xarray.dev/en/stable/api.html as expected.
xarray.pydata.org/en/stable/api.html is no longer redirecting to docs.xarray.dev/en/stable/api.html as expected.
Good catch... Forgot to check this
https://xarray.readthedocs.io/$rest -> https://docs.xarray.dev/ (it will only redirect for requests on the readthedocs.io domain).
this solution appears to be working for us tada . Thank you, @stsewd!
Sorry, I meant that those solutions we could implement in the future, that's not currently supported.