生产构建跳过本地开发证书
This commit is contained in:
@@ -5,16 +5,20 @@ import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const rootDir = path.resolve(__dirname, "../..");
|
||||
const httpsConfig = {
|
||||
|
||||
function getDevHttpsConfig() {
|
||||
return {
|
||||
key: fs.readFileSync(path.join(rootDir, "certs/localhost+2-key.pem")),
|
||||
cert: fs.readFileSync(path.join(rootDir, "certs/localhost+2.pem"))
|
||||
};
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
server: {
|
||||
export default defineConfig(({ command }) => ({
|
||||
server: command === "serve"
|
||||
? {
|
||||
port: 5174,
|
||||
strictPort: true,
|
||||
https: httpsConfig,
|
||||
https: getDevHttpsConfig(),
|
||||
headers: {
|
||||
// 关键:添加 COEP 和 COOP
|
||||
"Cross-Origin-Embedder-Policy": "credentialless", // 或 "require-corp"
|
||||
@@ -31,4 +35,5 @@ export default defineConfig({
|
||||
"/storage": "http://127.0.0.1:3001"
|
||||
}
|
||||
}
|
||||
});
|
||||
: undefined
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user