Fixed issue related to reverse proxy.

1) Fix reverse proxy redirection in server mode.
2) All reverse proxies in desktop mode.
pull/5528/head
Aditya Toshniwal 2022-11-14 18:58:36 +05:30 committed by GitHub
parent e701da7390
commit 998c0cb7b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -97,9 +97,6 @@ app.config['sessions'] = dict()
if setup_db_required:
setup.setup_db(app)
if config.SERVER_MODE:
app.wsgi_app = ReverseProxied(app.wsgi_app)
# Authentication sources
if len(config.AUTHENTICATION_SOURCES) > 0:
# Creating a temporary auth source list removing INTERNAL
@ -142,6 +139,9 @@ if 'PGADMIN_INT_KEY' in os.environ:
else:
app.PGADMIN_INT_KEY = ''
if not app.PGADMIN_RUNTIME:
app.wsgi_app = ReverseProxied(app.wsgi_app)
##########################################################################
# The entry point

View File

@ -123,13 +123,17 @@ class PgAdmin(Flask):
# like 'localhost/pgadmin4' then we have to append '/pgadmin4'
# into endpoints
#############################################################
wsgi_root_path = current_app.config.get("APPLICATION_ROOT", "/")
wsgi_root_path = None
if url_for('browser.index') != '/browser/':
wsgi_root_path = url_for('browser.index').replace(
'/browser/', ''
)
def get_full_url_path(url):
"""
Generate endpoint URL at per WSGI alias
"""
if wsgi_root_path != "/" and url:
if wsgi_root_path is not None and url:
return wsgi_root_path + url
else:
return url

View File

@ -846,4 +846,4 @@ def get_safe_post_login_redirect():
if url.startswith(item):
return url
return os.environ.get("SCRIPT_NAME", "/")
return url_for('browser.index')