feat:生产环境https协议校验

This commit is contained in:
weiwei committed 2025-08-15 17:29:48 +08:00
1 parent a8c03e3089
commit a472af7625
2 files changed
+22

No files matched your search

+14
View File
@@ -47,7 +47,21 @@ const https = new Request({
},
})
// 生产环境协议安全检查
const validateProductionSecurity = () => {
if (isDevEnv()) return
const apiUrl = import.meta.env.VITE_API_URL
if (apiUrl && !apiUrl.startsWith("https://")) {
uni.showToast({ title: "生产环境安全错误: 必须使用 HTTPS 协议", icon: "error" })
throw new Error("生产环境禁止使用 HTTP 协议")
}
}
https.interceptors.request.use(async (config) => {
// 生产环境协议检查
validateProductionSecurity()
const tokenStorage = uni.getStorageSync(TOKEN_KEY)
const config_header: any = config.header || {}