diff --git a/.github/workflows/main.yml b/.github/workflows/publish-docker-image.yml similarity index 96% rename from .github/workflows/main.yml rename to .github/workflows/publish-docker-image.yml index caf6414..01bbabb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/publish-docker-image.yml @@ -10,7 +10,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }}-explorer + IMAGE_NAME: logos-blockchain-explorer jobs: build-and-push: diff --git a/src/app.py b/src/app.py index 15107e5..5cc6ce7 100644 --- a/src/app.py +++ b/src/app.py @@ -6,8 +6,8 @@ from lifespan import lifespan from router import create_router -def create_app() -> FastAPI: - app = NBE(lifespan=lifespan) +def create_app(root_path) -> FastAPI: + app = NBE(lifespan=lifespan, root_path=root_path) app = mount_statics(app) app.include_router(create_router()) return app diff --git a/src/main.py b/src/main.py index 8bfd514..634487f 100644 --- a/src/main.py +++ b/src/main.py @@ -9,7 +9,8 @@ from logs import setup_logging async def main(): - app = create_app() + base_path = getenv("NBE_BASE_PATH", "").strip().rstrip("/") + app = create_app(base_path) host = getenv("NBE_HOST", "0.0.0.0") port = int(getenv("NBE_PORT", 8000)) diff --git a/static/app.js b/static/app.js index f83f9e8..d8457c9 100644 --- a/static/app.js +++ b/static/app.js @@ -9,6 +9,15 @@ import TransactionDetailPage from './pages/TransactionDetail.js'; const ROOT = document.getElementById('app'); + // Detect the Base Path from the HTML tag. + // If the tag is missing or equals "__BASE_PATH__", default to root "/". +const BASE_PATH = (() => { + const baseHref = document.querySelector('base')?.getAttribute('href'); + if (!baseHref || baseHref === "__BASE_PATH__") return '/'; + + return baseHref.endsWith('/') ? baseHref : `${baseHref}/`; +})(); + function LoadingScreen() { return h('main', { class: 'wrap' }, h('p', null, 'Loading...')); } @@ -47,7 +56,9 @@ function AppRouter() { re: route.re, view: route.view, })); - return h(Router, { routes: wired }); + + // Pass the base prop to the Router so it knows where internal links start + return h(Router, { routes: wired, base: BASE_PATH }); } try {