diff --git a/unitool.js b/unitool.js index cbe1e9e..ca78630 100644 --- a/unitool.js +++ b/unitool.js @@ -129,6 +129,10 @@ export default { port = window?.location?.port?.replace(':', '') } // #endif + if (!hostname) { + // 如果没有配置 hostname,又不是在 H5 环境,则最后的默认值是 localhost + hostname = 'localhost' + } return `${protocol}://${hostname}:${port}/${route.replace(/^\//, '')}` },