File tree Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -719,29 +719,24 @@ def alter_hostname_settings(
719
719
* args ,
720
720
** kwargs
721
721
) -> Any :
722
+ """Use the request headers to dynamically alter the content origin and api hostname.
723
+ This is useful in scenarios where the hub is accessible directly and through a
724
+ reverse proxy.
725
+ """
722
726
723
727
ALLOWED_KEYS = ['CONTENT_ORIGIN' , 'ANSIBLE_API_HOSTNAME' ]
724
728
725
- # if 'CACHE' in key.upper():
726
- # print(f'PID:{os.getpid()} READY:{apps.ready} KEY:{key} VAL:{value.value}')
727
-
728
729
if not apps .ready or key .upper () not in DYNAMIC_SETTINGS_SCHEMA :
729
730
# If app is starting up or key is not on allowed list bypass and just return the value
730
- if key .upper () in ALLOWED_KEYS :
731
- print (f"SKIPPING { key } " )
732
731
return value .value
733
732
734
733
if key .upper () in ALLOWED_KEYS :
735
734
req = get_current_request ()
736
735
if req is not None :
737
736
headers = dict (req .headers )
738
- print (f'REQ: { req } ' )
739
- print (f'REQ.headers: ...' )
740
- from pprint import pprint ; pprint (headers )
741
737
proto = headers .get ('X-Forwarded-Proto' , 'http' )
742
738
host = headers .get ('Host' , 'localhost:5001' )
743
739
baseurl = proto + '://' + host
744
- print (f'KEY:{ key } -> { baseurl } ' )
745
740
return baseurl
746
741
747
742
return temp_settings .get (key , value .value )
You can’t perform that action at this time.
0 commit comments