Fixed SocketIO calls when pgAdmin 4 server is running from a sub directory. #5521

This commit is contained in:
Aditya Toshniwal
2022-11-15 13:51:12 +05:30
committed by GitHub
parent c5e9aa6357
commit 669a3a7673
4 changed files with 20 additions and 11 deletions

View File

@@ -123,7 +123,7 @@ class PgAdmin(Flask):
# like 'localhost/pgadmin4' then we have to append '/pgadmin4'
# into endpoints
#############################################################
wsgi_root_path = None
wsgi_root_path = ''
if url_for('browser.index') != '/browser/':
wsgi_root_path = url_for('browser.index').replace(
'/browser/', ''
@@ -133,10 +133,7 @@ class PgAdmin(Flask):
"""
Generate endpoint URL at per WSGI alias
"""
if wsgi_root_path is not None and url:
return wsgi_root_path + url
else:
return url
return wsgi_root_path + url
# Fetch all endpoints and their respective url
for rule in current_app.url_map.iter_rules('static'):
@@ -147,6 +144,8 @@ class PgAdmin(Flask):
for rule in current_app.url_map.iter_rules(endpoint):
yield rule.endpoint, get_full_url_path(rule.rule)
yield 'pgadmin.root', wsgi_root_path
@property
def javascripts(self):
scripts = []
@@ -928,5 +927,5 @@ def create_app(app_name=None):
##########################################################################
# All done!
##########################################################################
socketio.init_app(app)
socketio.init_app(app, cors_allowed_origins="*")
return app