From d64683a6174def66ed5cb5bf914290064645096c Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Thu, 12 Dec 2024 00:59:44 +0800 Subject: [PATCH] fix: path --- lib/GetIPInfo.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/GetIPInfo.ts b/lib/GetIPInfo.ts index 5b335a9..33eb249 100644 --- a/lib/GetIPInfo.ts +++ b/lib/GetIPInfo.ts @@ -1,6 +1,7 @@ "use server"; import fs from "fs"; +import path from 'path'; import { AsnResponse, CityResponse, Reader } from "maxmind"; import { GetServerIP } from "./serverFetch"; @@ -17,8 +18,12 @@ export default async function GetIPInfo({ }): Promise { const ip = await GetServerIP({ server_id: Number(server_id) }); - const cityDbBuffer = fs.readFileSync("./lib/GeoLite2-City.mmdb"); - const asnDbBuffer = fs.readFileSync("./lib/GeoLite2-ASN.mmdb"); + const cityDbPath = path.join(process.cwd(),"lib", 'GeoLite2-City.mmdb'); + + const asnDbPath = path.join(process.cwd(),"lib", 'GeoLite2-ASN.mmdb'); + + const cityDbBuffer = fs.readFileSync(cityDbPath); + const asnDbBuffer = fs.readFileSync(asnDbPath); const cityLookup = new Reader(cityDbBuffer); const asnLookup = new Reader(asnDbBuffer);