first commit
This commit is contained in:
33
xterminal/demo/vite.https.config.mjs
Normal file
33
xterminal/demo/vite.https.config.mjs
Normal file
@@ -0,0 +1,33 @@
|
||||
import fs from "node:fs";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
/**
|
||||
* HTTPS 开发配置:
|
||||
* - 供 shell.biboer.cn 外部访问开发页面;
|
||||
* - 使用本机 acme 证书,避免浏览器证书不受信告警。
|
||||
*/
|
||||
const DEV_PUBLIC_HOST = "shell.biboer.cn";
|
||||
const DEV_CERT_PATH = "/Users/gavin/.acme.sh/shell.biboer.cn_ecc/fullchain.cer";
|
||||
const DEV_KEY_PATH = "/Users/gavin/.acme.sh/shell.biboer.cn_ecc/shell.biboer.cn.key";
|
||||
|
||||
if (!fs.existsSync(DEV_CERT_PATH) || !fs.existsSync(DEV_KEY_PATH)) {
|
||||
throw new Error(
|
||||
`HTTPS 证书文件不存在,请检查路径: cert=${DEV_CERT_PATH}, key=${DEV_KEY_PATH}`
|
||||
);
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
// demo 目录作为 Vite 根目录,保持当前示例结构不变。
|
||||
root: "demo",
|
||||
server: {
|
||||
host: "0.0.0.0",
|
||||
port: 5173,
|
||||
strictPort: true,
|
||||
https: {
|
||||
cert: fs.readFileSync(DEV_CERT_PATH),
|
||||
key: fs.readFileSync(DEV_KEY_PATH)
|
||||
},
|
||||
// 允许通过 shell.biboer.cn 访问 dev server。
|
||||
allowedHosts: [DEV_PUBLIC_HOST]
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user