diff --git a/.env.example b/.env.example index 074ff4835..71528b7a7 100644 --- a/.env.example +++ b/.env.example @@ -11,6 +11,7 @@ UVICORN_PORT = 8000 # UVICORN_SSL_CERTFILE = "/var/lib/marzban/certs/example.com/fullchain.pem" # UVICORN_SSL_KEYFILE = "/var/lib/marzban/certs/example.com/key.pem" +# DASHBOARD_PATH = "/dashboard/" # XRAY_JSON = "xray_config.json" # XRAY_SUBSCRIPTION_URL_PREFIX = "https://example.com" diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index c089bc1e2..6b5de84d3 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -23,7 +23,7 @@ jobs: - name: Build project working-directory: ./app/dashboard - run: VITE_BASE_API=/api/ npm run build --if-present -- --outDir build --base '/dashboard/' + run: VITE_BASE_API=/api/ npm run build --if-present -- --outDir build --assetsDir statics - name: Create 404.html working-directory: ./app/dashboard diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e93385a6..50449e2eb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: - name: Build project working-directory: ./app/dashboard - run: VITE_BASE_API=/api/ npm run build --if-present -- --outDir build --base '/dashboard/' + run: VITE_BASE_API=/api/ npm run build --if-present -- --outDir build --assetsDir statics - name: Create 404.html working-directory: ./app/dashboard diff --git a/app/dashboard/__init__.py b/app/dashboard/__init__.py index 713c142d6..43032c1e4 100644 --- a/app/dashboard/__init__.py +++ b/app/dashboard/__init__.py @@ -4,17 +4,17 @@ from pathlib import Path from app import app -from config import DEBUG, VITE_BASE_API +from config import DEBUG, VITE_BASE_API, DASHBOARD_PATH from fastapi.staticfiles import StaticFiles -path = '/dashboard/' base_dir = Path(__file__).parent build_dir = base_dir / 'build' +statics_dir = build_dir / 'statics' def build(): proc = subprocess.Popen( - ['npm', 'run', 'build', '--', '--base', path, '--outDir', build_dir], + ['npm', 'run', 'build', '--', '--outDir', build_dir, '--assetsDir', 'statics'], env={**os.environ, 'VITE_BASE_API': VITE_BASE_API}, cwd=base_dir ) @@ -27,7 +27,7 @@ def build(): def run_dev(): proc = subprocess.Popen( - ['npm', 'run', 'dev', '--', '--host', '0.0.0.0', '--base', path, '--clearScreen', 'false'], + ['npm', 'run', 'dev', '--', '--host', '0.0.0.0', '--clearScreen', 'false', '--base', os.path.join(DASHBOARD_PATH, '')], env={**os.environ, 'VITE_BASE_API': VITE_BASE_API}, cwd=base_dir ) @@ -40,10 +40,15 @@ def run_build(): build() app.mount( - path, + DASHBOARD_PATH, StaticFiles(directory=build_dir, html=True), name="dashboard" ) + app.mount( + '/statics/', + StaticFiles(directory=statics_dir, html=True), + name="statics" + ) @app.on_event("startup") diff --git a/app/dashboard/build/404.html b/app/dashboard/build/404.html index 733bfd19b..8f45a83ad 100644 --- a/app/dashboard/build/404.html +++ b/app/dashboard/build/404.html @@ -8,38 +8,38 @@ - + - + - + - - - + + +
-