This commit is contained in:
陆柯 2022-08-04 17:32:28 +08:00
parent c2b9f21ecc
commit 506dabb27f

View File

@ -122,7 +122,6 @@ export default {
return route return route
} }
const protocol = envar.servProtocol || (process.env.NODE_ENV === 'production' ? 'https' : 'http')
let hostname = envar.servHostname let hostname = envar.servHostname
let port = envar.servPort let port = envar.servPort
// #ifdef H5 // #ifdef H5
@ -134,10 +133,12 @@ export default {
} }
// #endif // #endif
if (!hostname) { if (!hostname) {
// 如果没有配置 hostname又不是在 H5 环境,则最后的默认值是 localhost // 如果没有配置 envar.servHostname又不是在 H5 环境,则最后的默认值是 localhost
hostname = 'localhost' hostname = 'localhost'
} }
const protocol = hostname === 'localhost' ? 'http' : envar.servProtocol || (process.env.NODE_ENV === 'production' ? 'https' : 'http')
return `${protocol}://${hostname}:${port}/${route.replace(/^\//, '')}` return `${protocol}://${hostname}:${port}/${route.replace(/^\//, '')}`
}, },