@@ -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,20 @@ 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 suffix, while those projects
726
+ # migrate to the new implementation, we will prefix special paths,
727
+ # they are manually un-prefixed in nginx.
728
+ if self .custom_prefix and self .has_feature (Feature .USE_PROXIED_APIS_WITH_PREFIX ):
729
+ return self .custom_prefix
724
730
if self .urlconf :
725
731
# Return the value before the first defined variable,
726
732
# as that is a prefix and not part of our normal doc patterns.
@@ -1930,6 +1936,7 @@ def add_features(sender, **kwargs):
1930
1936
DISABLE_PAGEVIEWS = "disable_pageviews"
1931
1937
RESOLVE_PROJECT_FROM_HEADER = "resolve_project_from_header"
1932
1938
USE_UNRESOLVER_WITH_PROXITO = "use_unresolver_with_proxito"
1939
+ USE_PROXIED_APIS_WITH_PREFIX = "use_proxied_apis_with_prefix"
1933
1940
ALLOW_VERSION_WARNING_BANNER = "allow_version_warning_banner"
1934
1941
1935
1942
# Versions sync related features
@@ -2020,6 +2027,12 @@ def add_features(sender, **kwargs):
2020
2027
"Proxito: Use new unresolver implementation for serving documentation files."
2021
2028
),
2022
2029
),
2030
+ (
2031
+ USE_PROXIED_APIS_WITH_PREFIX ,
2032
+ _ (
2033
+ "Proxito: Use proxied APIs (/_/*) with the custom prefix if the project has one (Project.custom_prefix)."
2034
+ ),
2035
+ ),
2023
2036
(
2024
2037
ALLOW_VERSION_WARNING_BANNER ,
2025
2038
_ ("Dashboard: Allow project to use the version warning banner." ),
0 commit comments