更新 astro.config.mjs
This commit is contained in:
@@ -4,15 +4,19 @@ import react from '@astrojs/react';
|
|||||||
import sitemap from '@astrojs/sitemap';
|
import sitemap from '@astrojs/sitemap';
|
||||||
import pkgs from './package.json';
|
import pkgs from './package.json';
|
||||||
import tailwindcss from '@tailwindcss/vite';
|
import tailwindcss from '@tailwindcss/vite';
|
||||||
|
import dotenv from 'dotenv';
|
||||||
|
|
||||||
|
dotenv.config();
|
||||||
const isDev = process.env.NODE_ENV === 'development';
|
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' };
|
const apiProxy = { target: target, changeOrigin: true, ws: true, rewriteWsOrigin: true, secure: false, cookieDomainRewrite: 'localhost' };
|
||||||
let proxy = {
|
let proxy = {
|
||||||
'/root/': {
|
'/root/': {
|
||||||
target: `${target}/root/`,
|
target: `${target}/root/`,
|
||||||
},
|
},
|
||||||
'/api': apiProxy,
|
'/api': apiProxy,
|
||||||
|
'/client': apiProxy,
|
||||||
};
|
};
|
||||||
|
|
||||||
const basename = isDev ? undefined : `${pkgs.basename}`;
|
const basename = isDev ? undefined : `${pkgs.basename}`;
|
||||||
@@ -27,7 +31,7 @@ export default defineConfig({
|
|||||||
vite: {
|
vite: {
|
||||||
plugins: [tailwindcss()],
|
plugins: [tailwindcss()],
|
||||||
define: {
|
define: {
|
||||||
basename: JSON.stringify(basename || ''),
|
BASE_NAME: JSON.stringify(basename || ''),
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
port: 7008,
|
port: 7008,
|
||||||
|
|||||||
Reference in New Issue
Block a user