feat(admin): set /admin base path for reverse proxy deployment
Configure Vite base, Vue Router history, axios baseURL and container Nginx to serve the admin panel under /admin/ path prefix. 🤖 Generated with [Qoder][https://qoder.com]
This commit is contained in:
@@ -3,7 +3,7 @@ import router from './router';
|
||||
import { clearStaffSession, reconcileStaffSessionFromToken, useAuthStore } from './stores/auth';
|
||||
import { ensureStaffSession, resetStaffSessionHydration } from './utils/session-hydrate';
|
||||
|
||||
const api = axios.create({ baseURL: '/api' });
|
||||
const api = axios.create({ baseURL: '/admin/api' });
|
||||
|
||||
let handling401 = false;
|
||||
let handling403Portal = false;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useAuthStore } from '../stores/auth';
|
||||
import { ensureStaffSession } from '../utils/session-hydrate';
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
history: createWebHistory('/admin'),
|
||||
routes: [
|
||||
{ path: '/login', component: () => import('../views/Login.vue'), meta: { public: true } },
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ import vue from '@vitejs/plugin-vue';
|
||||
import { resolve } from 'path';
|
||||
|
||||
export default defineConfig({
|
||||
base: '/admin/',
|
||||
plugins: [vue()],
|
||||
resolve: {
|
||||
// 避免 src 内遗留的 .js 抢先于 .ts/.vue 被解析(曾导致 i18n 文案缺失)
|
||||
@@ -15,6 +16,12 @@ export default defineConfig({
|
||||
publicDir: resolve(__dirname, '../../packages/shared/public'),
|
||||
server: {
|
||||
port: 5174,
|
||||
proxy: { '/api': { target: 'http://localhost:3000', changeOrigin: true } },
|
||||
proxy: {
|
||||
'/admin/api': {
|
||||
target: 'http://localhost:3000',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/admin\/api/, '/api'),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
8
apps/api/.env
Normal file
8
apps/api/.env
Normal file
@@ -0,0 +1,8 @@
|
||||
DATABASE_URL=postgresql://thebet365:thebet365@localhost:5432/thebet365
|
||||
REDIS_URL=redis://localhost:6379
|
||||
JWT_SECRET=dev-secret-change-in-production
|
||||
JWT_PLAYER_EXPIRES=24h
|
||||
JWT_ADMIN_EXPIRES=2h
|
||||
JWT_AGENT_EXPIRES=8h
|
||||
PORT=3000
|
||||
NODE_ENV=development
|
||||
Reference in New Issue
Block a user