Update hosts form

This commit is contained in:
2026-09-20 12:51:12 +01:00
parent 8b40a876a1
commit a9ebd8fb75
13 changed files with 198 additions and 67 deletions
+22
View File
@@ -0,0 +1,22 @@
import getInterfaceLocalIP from "@/src/functions/backend/setup/get-interface-local-ip";
import type { ApiReqParams } from "@/src/types";
import type {
APIResponseObject,
BunextAPIRouteHandler,
} from "@moduletrace/bunext/types";
export const handler: BunextAPIRouteHandler<APIResponseObject> = async (
params,
) => {
if (params.req.method !== "GET") {
return { success: false };
}
const url = new URL(params.req.url || "");
const iface = url.searchParams.get("interface") || undefined;
try {
const local_ip = await getInterfaceLocalIP(iface || null);
return { success: true, stringRes: local_ip };
} catch (error: any) {
return { success: false, msg: error.message };
}
};
+3 -1
View File
@@ -11,8 +11,10 @@ export const handler: BunextAPIRouteHandler<APIResponseObject> = async (
if (params.req.method !== "GET") {
return { success: false };
}
const url = new URL(params.req.url || "");
const iface = url.searchParams.get("interface") || undefined;
try {
const public_ip = await grabHostPublicIPAddress();
const public_ip = await grabHostPublicIPAddress(iface);
return { success: true, stringRes: public_ip };
} catch (error: any) {
return { success: false, msg: error.message };