Skip to content

Commit

Permalink
Restore SCRIPT_NAME after Flask app initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk committed Jun 27, 2019
1 parent 5e18f59 commit 2ce44c2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ckan/config/middleware/flask_app.py
Expand Up @@ -370,10 +370,14 @@ def can_handle_request(self, environ):
# Disable built-in flask's ability to prepend site root to
# generated url, as we are going to use locale and existing
# logic is not flexible enough for this purpose
if 'SCRIPT_NAME' in environ:
environ['SCRIPT_NAME'] = ''

original_script_name = environ.get('SCRIPT_NAME')
environ['SCRIPT_NAME'] = ''
urls = self.url_map.bind_to_environ(environ)
# Restore SCRIPT_NAME if this is not a flask request and there is
# a chance Pylons will generate X-Debug-URL which relies on this
# variable
environ['SCRIPT_NAME'] = original_script_name

try:
rule, args = urls.match(return_rule=True)
origin = 'core'
Expand Down

0 comments on commit 2ce44c2

Please sign in to comment.