更新 astro.config.mjs

This commit is contained in:
2025-11-24 12:56:44 +08:00
parent 203e26caf8
commit 0810a1be5d

View File

@@ -4,15 +4,19 @@ import react from '@astrojs/react';
import sitemap from '@astrojs/sitemap';
import pkgs from './package.json';
import tailwindcss from '@tailwindcss/vite';
import dotenv from 'dotenv';
dotenv.config();
const isDev = process.env.NODE_ENV === 'development';
let target = process.env.VITE_API_URL || 'https://localhost:51015';
let target = process.env.VITE_API_URL || 'http://localhost:51015';
const apiProxy = { target: target, changeOrigin: true, ws: true, rewriteWsOrigin: true, secure: false, cookieDomainRewrite: 'localhost' };
let proxy = {
'/root/': {
target: `${target}/root/`,
},
'/api': apiProxy,
'/client': apiProxy,
};
const basename = isDev ? undefined : `${pkgs.basename}`;
@@ -27,7 +31,7 @@ export default defineConfig({
vite: {
plugins: [tailwindcss()],
define: {
basename: JSON.stringify(basename || ''),
BASE_NAME: JSON.stringify(basename || ''),
},
server: {
port: 7008,