@@ -693,11 +693,9 @@ def proxied_api_host(self):
693
693
This needs to start with a slash at the root of the domain,
694
694
and end without a slash
695
695
"""
696
- if self .urlconf :
697
- # Add our proxied api host at the first place we have a $variable
698
- # This supports both subpaths & normal root hosting
699
- path_prefix = self .custom_path_prefix
700
- return unsafe_join_url_path (path_prefix , "/_" )
696
+ custom_prefix = self .proxied_api_prefix
697
+ if custom_prefix :
698
+ return unsafe_join_url_path (custom_prefix , "/_" )
701
699
return '/_'
702
700
703
701
@property
@@ -715,12 +713,22 @@ def proxied_static_path(self):
715
713
return f"{ self .proxied_api_host } /static/"
716
714
717
715
@property
718
- def custom_path_prefix (self ):
716
+ def proxied_api_prefix (self ):
719
717
"""
720
- Get the path prefix from the custom urlconf .
718
+ Get the path prefix for proxied API paths (``/_/``) .
721
719
722
720
Returns `None` if the project doesn't have a custom urlconf.
723
721
"""
722
+ # When using a custom prefix, we can only handle serving
723
+ # docs pages under the prefix, not special paths like `/_/`.
724
+ # Projects using the old implementation, need to proxy `/_/`
725
+ # paths as is, this is, without the prefix, while those projects
726
+ # migrate to the new implementation, we will prefix special paths
727
+ # when generating links, these paths will be manually un-prefixed in nginx.
728
+ if self .custom_prefix and self .has_feature (
729
+ Feature .USE_PROXIED_APIS_WITH_PREFIX
730
+ ):
731
+ return self .custom_prefix
724
732
if self .urlconf :
725
733
# Return the value before the first defined variable,
726
734
# as that is a prefix and not part of our normal doc patterns.
@@ -1930,6 +1938,7 @@ def add_features(sender, **kwargs):
1930
1938
DISABLE_PAGEVIEWS = "disable_pageviews"
1931
1939
RESOLVE_PROJECT_FROM_HEADER = "resolve_project_from_header"
1932
1940
USE_UNRESOLVER_WITH_PROXITO = "use_unresolver_with_proxito"
1941
+ USE_PROXIED_APIS_WITH_PREFIX = "use_proxied_apis_with_prefix"
1933
1942
ALLOW_VERSION_WARNING_BANNER = "allow_version_warning_banner"
1934
1943
1935
1944
# Versions sync related features
@@ -2020,6 +2029,12 @@ def add_features(sender, **kwargs):
2020
2029
"Proxito: Use new unresolver implementation for serving documentation files."
2021
2030
),
2022
2031
),
2032
+ (
2033
+ USE_PROXIED_APIS_WITH_PREFIX ,
2034
+ _ (
2035
+ "Proxito: Use proxied APIs (/_/*) with the custom prefix if the project has one (Project.custom_prefix)."
2036
+ ),
2037
+ ),
2023
2038
(
2024
2039
ALLOW_VERSION_WARNING_BANNER ,
2025
2040
_ ("Dashboard: Allow project to use the version warning banner." ),
0 commit comments