update at 2026-02-14 14:39:57

This commit is contained in:
douboer
2026-02-14 14:39:57 +08:00
parent 978d986c13
commit a57cc3897b
2 changed files with 46 additions and 7 deletions

View File

@@ -1,12 +1,20 @@
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { readFileSync } from 'node:fs';
import { readFileSync, existsSync } from 'node:fs';
import { homedir } from 'node:os';
import { join } from 'node:path';
const certDir = join(homedir(), 'mac.biboer.cn_ecc');
const httpsCert = readFileSync(join(certDir, 'fullchain.cer'));
const httpsKey = readFileSync(join(certDir, 'mac.biboer.cn.key'));
const certPath = join(certDir, 'fullchain.cer');
const keyPath = join(certDir, 'mac.biboer.cn.key');
// 只在证书存在时启用 HTTPS开发环境
const httpsConfig = existsSync(certPath) && existsSync(keyPath)
? {
cert: readFileSync(certPath),
key: readFileSync(keyPath)
}
: undefined;
export default defineConfig({
plugins: [vue()],
@@ -15,9 +23,6 @@ export default defineConfig({
port: 5173,
strictPort: true,
allowedHosts: ['mac.biboer.cn'],
https: {
cert: httpsCert,
key: httpsKey
}
https: httpsConfig
}
});