From f58e572558ea9eaf89598e0a5e5cda05fa7670ab Mon Sep 17 00:00:00 2001 From: leviofanh Date: Thu, 18 Dec 2025 06:40:52 +0100 Subject: [PATCH] Fix: Fixed support for WGDashboardClient, now its static files are processed separately --- src/client.py | 11 ++++++++++- src/dashboard.py | 3 ++- src/static/client/index.html | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/client.py b/src/client.py index 67c84c9b..773109fd 100644 --- a/src/client.py +++ b/src/client.py @@ -4,8 +4,9 @@ from tzlocal import get_localzone from functools import wraps -from flask import Blueprint, render_template, abort, request, Flask, current_app, session, redirect, url_for +from flask import Blueprint, render_template, abort, request, Flask, current_app, session, redirect, url_for, send_from_directory import os +import mimetypes from modules.WireguardConfiguration import WireguardConfiguration from modules.DashboardConfig import DashboardConfig @@ -192,6 +193,14 @@ def createClientBlueprint(wireguardConfigurations: dict[WireguardConfiguration], }) return ResponseObject(status, msg) + @client.get(f'{prefix}/assets/') + @client.get(f'{prefix}/img/') + def serve_client_static(filename): + client_dist_folder = os.path.abspath("./static/dist/WGDashboardClient") + mimetype = mimetypes.guess_type(filename)[0] + subfolder = 'assets' if 'assets' in request.path else 'img' + return send_from_directory(os.path.join(client_dist_folder, subfolder), os.path.basename(filename), mimetype=mimetype) + @client.get(prefix) def ClientIndex(): app_prefix = dashboardConfig.GetConfig("Server", "app_prefix")[1] diff --git a/src/dashboard.py b/src/dashboard.py index 76a719bf..4360f93a 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -255,7 +255,8 @@ def auth_req(): 'getDashboardTheme', 'getDashboardVersion', 'sharePeer/get', 'isTotpEnabled', 'locale', '/fileDownload', '/client', - '/assets/', '/img/', '/json/' + '/assets/', '/img/', '/json/', + '/client/assets/', '/client/img/' ] if (("username" not in session or session.get("role") != "admin") diff --git a/src/static/client/index.html b/src/static/client/index.html index c58f6ee1..e359b6cb 100644 --- a/src/static/client/index.html +++ b/src/static/client/index.html @@ -2,7 +2,7 @@ - + WGDashboard Client