Skip to content

Commit cf3b742

Browse files
authored
Merge pull request #6768 from readthedocs/force-use-proxied-api
Force to use proxied API for footer and search
2 parents 1dc777b + 31efd4c commit cf3b742

File tree

9 files changed

+6
-21
lines changed

9 files changed

+6
-21
lines changed

readthedocs/core/static-src/core/js/doc-embed/footer.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,9 @@ function init() {
6262
get_data['subproject'] = true;
6363
}
6464

65-
// Check for new logic around proxying requests.
66-
// ``proxied_api_host`` won't exist on existing built docs,
67-
// so default to ``api_host`` in those cases
68-
var real_api_host = rtd.api_host;
69-
if ("proxied_api_host" in rtd) {
70-
real_api_host = rtd.proxied_api_host;
71-
}
72-
7365
// Get footer HTML from API and inject it into the page.
7466
$.ajax({
75-
url: real_api_host + "/api/v2/footer_html/",
67+
url: rtd.proxied_api_host + "/api/v2/footer_html/",
7668
crossDomain: true,
7769
xhrFields: {
7870
withCredentials: true,

readthedocs/core/static-src/core/js/doc-embed/rtd-data.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ function get() {
5959

6060
$.extend(config, defaults, window.READTHEDOCS_DATA);
6161

62+
// Force to use new settings
63+
config.proxied_api_host = '/_';
64+
6265
return config;
6366
}
6467

readthedocs/core/static-src/core/js/doc-embed/search.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ function attach_elastic_search_query(data) {
4444
var project = data.project;
4545
var version = data.version;
4646
var language = data.language || 'en';
47-
var api_host = data.api_host;
4847

4948
var query_override = function (query) {
5049
var search_def = $.Deferred();
5150
var search_url = document.createElement('a');
5251

53-
search_url.href = api_host;
54-
search_url.pathname = '/api/v2/docsearch/';
52+
search_url.href = data.proxied_api_host + '/api/v2/docsearch/';
5553
search_url.search = '?q=' + $.urlencode(query) + '&project=' + project +
5654
'&version=' + version + '&language=' + language;
5755

readthedocs/core/static/core/js/readthedocs-doc-embed.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readthedocs/doc_builder/backends/mkdocs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ def generate_rtd_data(self, docs_dir, mkdocs_config):
249249
'docroot': docs_dir,
250250
'source_suffix': '.md',
251251
'api_host': settings.PUBLIC_API_URL,
252-
'proxied_api_host': settings.RTD_PROXIED_API_URL,
253252
'ad_free': not self.project.show_advertising,
254253
'commit': self.version.project.vcs_repo(self.version.slug).commit,
255254
'global_analytics_code': settings.GLOBAL_ANALYTICS_CODE,

readthedocs/doc_builder/backends/sphinx.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ def get_config_params(self):
151151
'settings': settings,
152152
'conf_py_path': conf_py_path,
153153
'api_host': settings.PUBLIC_API_URL,
154-
'proxied_api_host': settings.RTD_PROXIED_API_URL,
155154
'commit': self.project.vcs_repo(self.version.slug).commit,
156155
'versions': versions,
157156
'downloads': downloads,

readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ context = {
9696
'single_version': {{ project.single_version }},
9797
'conf_py_path': '{{ conf_py_path }}',
9898
'api_host': '{{ api_host }}',
99-
'proxied_api_host': '{{ proxied_api_host }}',
10099
'github_user': '{{ github_user }}',
101100
'github_repo': '{{ github_repo }}',
102101
'github_version': '{{ github_version }}',

readthedocs/settings/base.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ class CommunityBaseSettings(Settings):
4141
PUBLIC_DOMAIN_USES_HTTPS = False
4242
USE_SUBDOMAIN = False
4343
PUBLIC_API_URL = 'https://{}'.format(PRODUCTION_DOMAIN)
44-
# Some endpoints from the API can be proxied on other domain
45-
# or use the same domain where the docs are being served
46-
# (omit the host if that's the case).
47-
RTD_PROXIED_API_URL = PUBLIC_API_URL
4844
RTD_EXTERNAL_VERSION_DOMAIN = 'external-builds.readthedocs.io'
4945

5046
# Doc Builder Backends

readthedocs/settings/docker_compose.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class DockerBaseSettings(CommunityDevSettings):
1818
PRODUCTION_DOMAIN = 'community.dev.readthedocs.io'
1919
PUBLIC_DOMAIN = 'community.dev.readthedocs.io'
2020
PUBLIC_API_URL = f'http://{PRODUCTION_DOMAIN}'
21-
RTD_PROXIED_API_URL = PUBLIC_API_URL
2221
SLUMBER_API_HOST = 'http://web:8000'
2322
RTD_EXTERNAL_VERSION_DOMAIN = 'org.dev.readthedocs.build'
2423

0 commit comments

Comments
 (0)