部署正式环境

This commit is contained in:
eafonyang
2026-08-11 16:45:25 +08:00
parent 0e071f1ccb
commit 65281a734a
6 changed files with 118 additions and 4 deletions
+9 -4
View File
@@ -6,10 +6,12 @@ export default defineNuxtConfig({
css: ['~/assets/css/main.css'],
// 运行时配置:NUXT_PUBLIC_API_BASE_URL / NUXT_PUBLIC_ASSET_BASE_URL 环境变量可覆盖
// 生产构建(nuxt build/generateNODE_ENV=production)走同源相对路径 /api,由 nginx 反代到 backend
// 开发(pnpm dev)直连本地后端。显式传入的 NUXT_PUBLIC_* 环境变量仍可覆盖。
// 注:Nuxt 默认只加载 .env,不会自动读 .env.production,故用 NODE_ENV 区分环境。
runtimeConfig: {
public: {
apiBaseUrl: 'http://localhost:8083/api',
apiBaseUrl: process.env.NODE_ENV === 'production' ? '/api' : 'http://localhost:8083/api',
// 素材静态服务地址(用于解析 /uploads/... 相对路径),为空时默认取 apiBaseUrl 的 origin
assetBaseUrl: ''
}
@@ -24,8 +26,11 @@ export default defineNuxtConfig({
],
langDir: 'locales',
defaultLocale: 'zh',
// SEO 标签(canonical / hreflang)所需的站点基础 URL,部署时通过环境变量配置
baseUrl: process.env.NUXT_PUBLIC_SITE_URL || 'http://localhost:3100',
// SEO 标签(canonical / hreflang)所需的站点基础 URL:显式 NUXT_PUBLIC_SITE_URL 优先,
// 否则生产默认正式域名、开发默认本地 dev 地址
baseUrl:
process.env.NUXT_PUBLIC_SITE_URL ||
(process.env.NODE_ENV === 'production' ? 'https://www.luxsin.com.cn' : 'http://localhost:3100'),
strategy: 'prefix_except_default',
detectBrowserLanguage: {
useCookie: true,