@@ -211,22 +211,16 @@ class="btn btn-default pa-btn pa-btn-delete"
211211
212212<script>
213213
214- const protocol = window.location.protocol;
215- const host = window.location.hostname;
216- const port = getSetting("GRAPHQL_PORT");
217- const apiToken = getSetting("API_TOKEN");
214+ const apiToken = getSetting("API_TOKEN");
215+ const apiBaseUrl = getApiBase();
218216
219217 // ----------------------------------------------------------------
220218 function manualnmapscan(targetip, mode) {
221219 $("#scanoutput").empty();
222220
223-
224- const baseUrl = getApiBase();
225-
226-
227221 $.ajax({
228222 method: "POST",
229- url: `${baseUrl }/nettools/nmap`,
223+ url: `${apiBaseUrl }/nettools/nmap`,
230224 contentType: "application/json",
231225 dataType: "json",
232226 data: JSON.stringify({
@@ -265,7 +259,7 @@ function speedtestcli() {
265259
266260 $.ajax({
267261 method: "GET",
268- url: `${protocol}//${host}:${port }/nettools/speedtest`,
262+ url: `${apiBaseUrl }/nettools/speedtest`,
269263 headers: {
270264 "Authorization": "Bearer " + apiToken,
271265 "Content-Type": "application/json"
@@ -316,7 +310,7 @@ function traceroute() {
316310
317311 $.ajax({
318312 method: "POST",
319- url: `${protocol}//${host}:${port }/nettools/traceroute`,
313+ url: `${apiBaseUrl }/nettools/traceroute`,
320314 headers: {
321315 "Authorization": "Bearer " + apiToken,
322316 "Content-Type": "application/json"
@@ -362,11 +356,9 @@ function nslookup() {
362356
363357 $("#nslookupoutput").empty();
364358
365-
366-
367359 $.ajax({
368360 method: "POST",
369- url: `${protocol}//${host}:${port }/nettools/nslookup`,
361+ url: `${apiBaseUrl }/nettools/nslookup`,
370362 headers: {
371363 "Authorization": "Bearer " + apiToken,
372364 "Content-Type": "application/json"
@@ -450,7 +442,7 @@ function wakeonlan() {
450442
451443 $.ajax({
452444 method: "POST",
453- url: `${protocol}//${host}:${port }/nettools/wakeonlan`,
445+ url: `${apiBaseUrl }/nettools/wakeonlan`,
454446 headers: {
455447 "Authorization": "Bearer " + apiToken,
456448 "Content-Type": "application/json"
@@ -492,7 +484,7 @@ function copyFromDevice() {
492484
493485 $.ajax({
494486 method: "POST",
495- url: `${protocol}//${host}:${port }/device/copy`,
487+ url: `${apiBaseUrl }/device/copy`,
496488 headers: {
497489 "Authorization": "Bearer " + apiToken,
498490 "Content-Type": "application/json"
@@ -585,18 +577,14 @@ function deleteDeviceEvents () {
585577 return;
586578 }
587579
588- const protocol = window.location.protocol; // "http:" or "https:"
589- const host = window.location.hostname; // current hostname
590- const port = getSetting("GRAPHQL_PORT"); // your dynamic port
591580 const apiToken = getSetting("API_TOKEN"); // optional token if needed
592581
593- // Build base URL dynamically
594- const baseUrl = getApiBase();
582+
595583
596584 // Delete device events
597585 $.ajax({
598586 method: "DELETE",
599- url: `${baseUrl }/device/${encodeURIComponent(mac)}/events/delete`,
587+ url: `${apiBaseUrl }/device/${encodeURIComponent(mac)}/events/delete`,
600588 headers: {
601589 "Authorization": "Bearer " + apiToken
602590 },
@@ -641,11 +629,9 @@ function resetDeviceProps () {
641629 return;
642630 }
643631
644- const baseUrl = getApiBase();
645-
646632 $.ajax({
647633 method: "POST",
648- url: `${baseUrl }/device/${encodeURIComponent(mac)}/reset-props`,
634+ url: `${apiBaseUrl }/device/${encodeURIComponent(mac)}/reset-props`,
649635 dataType: "json",
650636 headers: {
651637 "Authorization": "Bearer " + apiToken
@@ -675,7 +661,7 @@ function internetinfo() {
675661
676662 $.ajax({
677663 method: "GET",
678- url: `${protocol}//${host}:${port }/nettools/internetinfo`,
664+ url: `${apiBaseUrl }/nettools/internetinfo`,
679665 headers: {
680666 "Authorization": "Bearer " + apiToken,
681667 "Content-Type": "application/json"
0 commit comments