From a340964c82242c66c6f6a34c86b03e3722465a7f Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 8 Oct 2023 00:10:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96=E7=99=BB?= =?UTF-8?q?=E5=BD=95=20ip=20=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/config/util.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/back/config/util.ts b/back/config/util.ts index 28229af8..5c586983 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -84,6 +84,11 @@ export async function getNetIp(req: any) { if (ip.includes('127.0') || ip.includes('192.168') || ip.includes('10.7')) { ip = ''; } + + if (!ip) { + return { address: `获取失败`, ip }; + } + try { const baiduApi = got .get(`https://www.cip.cc/${ip}`, { timeout: 10000, retry: 0 })