From 79c979c5ee3342bcd3493dd5b8ea9d04ad4ab5ce Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Thu, 2 Mar 2023 12:16:59 -0500 Subject: [PATCH] Canonical redirects: check if the project supports custom domains In .com need to check for this. But we don't allow users to create custom domains if they don't have the right subscription, so not sure if this is really needed.. It can be useful only if a user downgrades their subscription I guess. --- readthedocs/proxito/views/serve.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/readthedocs/proxito/views/serve.py b/readthedocs/proxito/views/serve.py index 2ea3f53c12f..c35b851153e 100644 --- a/readthedocs/proxito/views/serve.py +++ b/readthedocs/proxito/views/serve.py @@ -14,7 +14,7 @@ from readthedocs.builds.constants import EXTERNAL, INTERNAL, LATEST, STABLE from readthedocs.builds.models import Version from readthedocs.core.mixins import CDNCacheControlMixin -from readthedocs.core.resolver import resolve_path +from readthedocs.core.resolver import resolve_path, resolver from readthedocs.core.unresolver import ( InvalidExternalVersionError, InvalidPathForVersionedProjectError, @@ -281,7 +281,8 @@ def _get_canonical_redirect_type(self, request): .filter(canonical=True, https=True) .exists() ) - if canonical_domain: + # For .com we need to check if the project supports custom domains. + if canonical_domain and resolver._use_cname(project): log.debug( "Proxito Public Domain -> Canonical Domain Redirect.", project_slug=project.slug,