diff --git a/gdbgui/server/app.py b/gdbgui/server/app.py index 72377833..86e4c87f 100644 --- a/gdbgui/server/app.py +++ b/gdbgui/server/app.py @@ -6,6 +6,7 @@ from flask import Flask, abort, request, session from flask_compress import Compress # type: ignore from flask_socketio import SocketIO, emit # type: ignore +from werkzeug.middleware.proxy_fix import ProxyFix from .constants import DEFAULT_GDB_EXECUTABLE, STATIC_DIR, TEMPLATE_DIR from .http_routes import blueprint @@ -15,6 +16,7 @@ logger = logging.getLogger(__file__) # Create flask application and add some configuration keys to be used in various callbacks app = Flask(__name__, template_folder=str(TEMPLATE_DIR), static_folder=str(STATIC_DIR)) +app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1,x_prefix=1) Compress( app ) # add gzip compression to Flask. see https://github.com/libwilliam/flask-compress diff --git a/gdbgui/src/js/GdbApi.tsx b/gdbgui/src/js/GdbApi.tsx index a69167ba..890c932f 100644 --- a/gdbgui/src/js/GdbApi.tsx +++ b/gdbgui/src/js/GdbApi.tsx @@ -37,6 +37,7 @@ if (debug) { // @ts-expect-error ts-migrate(2339) FIXME: Property 'initial_data' does not exist on type 'Wi... Remove this comment to see the full error message const initial_data = window.initial_data; let socket: SocketIOClient.Socket; +const base = window.location.pathname.replace(/\/$/, ''); const GdbApi = { getSocket: function() { return socket; @@ -49,7 +50,8 @@ const GdbApi = { csrf_token: initial_data.csrf_token, gdbpid: initial_data.gdbpid, gdb_command: initial_data.gdb_command - } + }, + path: base + '/socket.io', }); socket.on("connect", function() { diff --git a/gdbgui/src/js/ajaxOverride.ts b/gdbgui/src/js/ajaxOverride.ts new file mode 100644 index 00000000..cb587c63 --- /dev/null +++ b/gdbgui/src/js/ajaxOverride.ts @@ -0,0 +1,13 @@ +const originalAjax = $.ajax; +const base = window.location.pathname.replace(/\/$/, ''); +console.log("AjaxOverride"); + +$.ajax = function (options: any) { + // You can customize the options here + const modifiedOptions = { + ...options, + url: base + options.url + }; + + return originalAjax.call(this, modifiedOptions); +}; diff --git a/gdbgui/src/js/constants.ts b/gdbgui/src/js/constants.ts index 690f6e33..e40f440b 100644 --- a/gdbgui/src/js/constants.ts +++ b/gdbgui/src/js/constants.ts @@ -1,3 +1,5 @@ +import './ajaxOverride' + let constants = { ENTER_BUTTON_NUM: 13, TAB_BUTTON_NUM: 9, diff --git a/gdbgui/templates/dashboard.html b/gdbgui/templates/dashboard.html index 27824c1c..859a332f 100644 --- a/gdbgui/templates/dashboard.html +++ b/gdbgui/templates/dashboard.html @@ -7,6 +7,9 @@ + + +
Loading dashboard...
@@ -15,5 +18,5 @@ window.csrf_token = {{csrf_token | tojson}} window.default_command = {{default_command | tojson}} - + diff --git a/gdbgui/templates/gdbgui.html b/gdbgui/templates/gdbgui.html index 5d469ae2..88eb0c79 100644 --- a/gdbgui/templates/gdbgui.html +++ b/gdbgui/templates/gdbgui.html @@ -18,24 +18,25 @@

Loading application, please wait.

- - + + + - - - - - - - - + + + + + + + + - + {% for theme in themes %} - + {% endfor %}