From 32c15dbd1d771fab7026365a092704813fb37e7a Mon Sep 17 00:00:00 2001 From: safavimohadeseh78 Date: Mon, 3 Aug 2026 14:28:06 +0200 Subject: [PATCH] Fix production deploy under /admin/ with correct Vite base path and server config. Co-authored-by: Cursor --- deploy/nginx-admin.conf | 17 +++++++++++++++++ index.html | 2 +- public/.htaccess | 18 ++++++++++++++++++ vite.config.ts | 7 ++++--- 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 deploy/nginx-admin.conf create mode 100644 public/.htaccess diff --git a/deploy/nginx-admin.conf b/deploy/nginx-admin.conf new file mode 100644 index 0000000..748341e --- /dev/null +++ b/deploy/nginx-admin.conf @@ -0,0 +1,17 @@ +# Example: admin panel at https://parche.montech.ir/admin/ +# Place dist/ contents in the server path mapped to /admin/ + +location /admin/ { + alias /var/www/parche/admin/; + try_files $uri $uri/ /admin/index.html; +} + +location ~ ^/admin/assets/ { + alias /var/www/parche/admin/assets/; + expires 7d; + add_header Cache-Control "public, immutable"; + types { + application/javascript js; + text/css css; + } +} diff --git a/index.html b/index.html index 7c66b35..0568cae 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,7 @@ - + پنل مدیریت | پَر فام بافت diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..ec82b63 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,18 @@ + + RewriteEngine On + RewriteBase /admin/ + + # Serve existing files and directories + RewriteCond %{REQUEST_FILENAME} -f [OR] + RewriteCond %{REQUEST_FILENAME} -d + RewriteRule ^ - [L] + + # SPA fallback + RewriteRule ^ index.html [L] + + + + AddType application/javascript .js + AddType text/css .css + AddType application/wasm .wasm + diff --git a/vite.config.ts b/vite.config.ts index ace127e..eb6b00a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,15 +6,16 @@ import vueJsx from '@vitejs/plugin-vue-jsx' import vueDevTools from 'vite-plugin-vue-devtools' // https://vite.dev/config/ -export default defineConfig({ +export default defineConfig(({ mode }) => ({ + base: '/admin/', plugins: [ vue(), vueJsx(), - vueDevTools(), + ...(mode === 'development' ? [vueDevTools()] : []), ], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, -}) +}))