Skip to content

Commit 02ad828

Browse files
committed
EmbedAPI: allow CORS for /api/v3/embed/
EmbedAPIv3 supports internal and external sites. When the site is internal, we can perform the same checks as we were doing: the version has to be public to allow it. On the case for external sites, we can always allow it since the site is public.
1 parent 9d2d1a2 commit 02ad828

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

readthedocs/core/signals.py

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
'/api/v2/search',
2222
'/api/v2/docsearch',
2323
'/api/v2/embed',
24+
'/api/v3/embed',
2425
]
2526

2627
webhook_github = Signal(providing_args=['project', 'data', 'event'])
@@ -76,6 +77,12 @@ def decide_if_cors(sender, request, **kwargs): # pylint: disable=unused-argumen
7677
url = request.GET.get('url')
7778
if url:
7879
unresolved = unresolve(url)
80+
if unresolved is None:
81+
# NOTE: Embed APIv3 now supports external sites. In that case
82+
# ``unresolve()`` will return None and we want to allow it
83+
# since the target is a public project.
84+
return True
85+
7986
project = unresolved.project
8087
version_slug = unresolved.version_slug
8188
else:

0 commit comments

Comments
 (0)