readthedocs.org icon indicating copy to clipboard operation
readthedocs.org copied to clipboard

Forced redirect `/$rest -> example.com` redirects PR previews (external domain) to target domain

Open andersy005 opened this issue 1 year ago • 6 comments

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

andersy005 avatar Sep 21 '22 18:09 andersy005

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).

stsewd avatar Sep 21 '22 19:09 stsewd

And other solution could be to ignore user redirects when serving PR previews.

stsewd avatar Sep 21 '22 19:09 stsewd

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!

andersy005 avatar Sep 22 '22 18:09 andersy005

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.

jhamman avatar Sep 22 '22 18:09 jhamman

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

andersy005 avatar Sep 22 '22 18:09 andersy005

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.

stsewd avatar Sep 22 '22 18:09 stsewd