fix(admin-panel): serve assets under /admin/ for same-host path deploy

Default Vite base to /admin/ (ADMIN_PANEL_BASE) so Dokploy Path+/admin + Strip Path resolves assets instead of the user app root.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
s.esmaeili
2026-10-31 23:24:46 +03:30
co-authored by Cursor
parent 7b0bbc072c
commit 032fa800d9
151 changed files with 164 additions and 150 deletions
+6 -5
View File
@@ -16,15 +16,16 @@ export default defineConfig(({ mode }) => {
const rootEnv = loadEnv(mode, fileURLToPath(new URL('../..', import.meta.url)), '');
const port = Number(rootEnv.ADMIN_PANEL_PORT ?? 5180);
const apiPort = Number(rootEnv.API_PORT ?? 3000);
// Same-host deploy: user app at `/`, admin at `/admin` (Dokploy Path + Strip Path).
// Browser still loads `/admin/assets/…`; the proxy strips `/admin` before nginx.
// Subdomain-only deploys can set ADMIN_PANEL_BASE=/ . Vite requires a trailing slash.
const rawBase = (rootEnv.ADMIN_PANEL_BASE || '/admin/').trim() || '/admin/';
const adminBase = rawBase.endsWith('/') ? rawBase : `${rawBase}/`;
return {
envDir: fileURLToPath(new URL('../..', import.meta.url)),
// Admin is served on its own subdomain (e.g. adm.bnk…), so assets must be
// rooted at `/`. Legacy used publicPath `admin/` because it shared a host
// path; keeping that here made index.html request `/admin/assets/…` while
// the image only has `/assets/…` → white screen 404.
// Branch mode still mounts under `/branch/` when that mode is used.
base: isBranch ? '/branch/' : '/',
base: isBranch ? '/branch/' : adminBase,
// Build number + «what changed» notes → version.json (scripts/app-version.mjs).
plugins: [
vue(),