diff --git a/lib/GetIPInfo.ts b/lib/GetIPInfo.ts index 1ce71e3..ea526d4 100644 --- a/lib/GetIPInfo.ts +++ b/lib/GetIPInfo.ts @@ -2,6 +2,7 @@ import maxmind, { CityResponse, AsnResponse } from 'maxmind'; import { GetServerIP } from './serverFetch'; +import path from 'path'; type IPInfo = { city: CityResponse; @@ -9,11 +10,14 @@ type IPInfo = { } export default async function GetIPInfo({ server_id }: { server_id: string }): Promise { - const ip = await GetServerIP({ server_id: Number(server_id) }) + + // 使用 path.join 获取正确的文件路径 + const cityDbPath = path.join(process.cwd(), 'lib', 'GeoLite2-City.mmdb'); + const asnDbPath = path.join(process.cwd(), 'lib', 'GeoLite2-ASN.mmdb'); - const cityLookup = await maxmind.open('./lib/GeoLite2-City.mmdb') - const asnLookup = await maxmind.open('./lib/GeoLite2-ASN.mmdb') + const cityLookup = await maxmind.open(cityDbPath) + const asnLookup = await maxmind.open(asnDbPath) return { city: cityLookup.get(ip) as CityResponse,