Use getApiBase() to get GraphQL Endpoint.

This commit is contained in:
netalertx-fedora
2026-01-09 22:39:42 +01:00
parent 82041f391f
commit 00a1875665

View File

@@ -210,23 +210,20 @@
<div id="scanoutput" style="margin-top: 30px;"></div> <div id="scanoutput" style="margin-top: 30px;"></div>
<script> <script>
// Build base URL dynamically
const protocol = window.location.protocol; const apiBase = getApiBase();
const host = window.location.hostname;
const port = getSetting("GRAPHQL_PORT");
const apiToken = getSetting("API_TOKEN"); const apiToken = getSetting("API_TOKEN");
// ---------------------------------------------------------------- // ----------------------------------------------------------------
function manualnmapscan(targetip, mode) { function manualnmapscan(targetip, mode) {
$("#scanoutput").empty(); $("#scanoutput").empty();
// Build base URL dynamically
const baseUrl = getApiBase(); const apiBase = getApiBase();
$.ajax({ $.ajax({
method: "POST", method: "POST",
url: `${baseUrl}/nettools/nmap`, url: `${apiBase}/nettools/nmap`,
contentType: "application/json", contentType: "application/json",
dataType: "json", dataType: "json",
data: JSON.stringify({ data: JSON.stringify({
@@ -265,7 +262,7 @@
$.ajax({ $.ajax({
method: "GET", method: "GET",
url: `${protocol}//${host}:${port}/nettools/speedtest`, url: `${apiBase}/nettools/speedtest`,
headers: { headers: {
"Authorization": "Bearer " + apiToken, "Authorization": "Bearer " + apiToken,
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -316,7 +313,7 @@
$.ajax({ $.ajax({
method: "POST", method: "POST",
url: `${protocol}//${host}:${port}/nettools/traceroute`, url: `${apiBase}/nettools/traceroute`,
headers: { headers: {
"Authorization": "Bearer " + apiToken, "Authorization": "Bearer " + apiToken,
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -366,7 +363,7 @@
$.ajax({ $.ajax({
method: "POST", method: "POST",
url: `${protocol}//${host}:${port}/nettools/nslookup`, url: `${apiBase}/nettools/nslookup`,
headers: { headers: {
"Authorization": "Bearer " + apiToken, "Authorization": "Bearer " + apiToken,
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -450,7 +447,7 @@
$.ajax({ $.ajax({
method: "POST", method: "POST",
url: `${protocol}//${host}:${port}/nettools/wakeonlan`, url: `${apiBase}/nettools/wakeonlan`,
headers: { headers: {
"Authorization": "Bearer " + apiToken, "Authorization": "Bearer " + apiToken,
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -492,7 +489,7 @@
$.ajax({ $.ajax({
method: "POST", method: "POST",
url: `${protocol}//${host}:${port}/device/copy`, url: `${apiBase}/device/copy`,
headers: { headers: {
"Authorization": "Bearer " + apiToken, "Authorization": "Bearer " + apiToken,
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -585,18 +582,14 @@
return; return;
} }
const protocol = window.location.protocol; // "http:" or "https:"
const host = window.location.hostname; // current hostname
const port = getSetting("GRAPHQL_PORT"); // your dynamic port
const apiToken = getSetting("API_TOKEN"); // optional token if needed
// Build base URL dynamically // Build base URL dynamically
const baseUrl = getApiBase(); const apiBase = getApiBase();
const apiToken = getSetting("API_TOKEN"); // optional token if needed
// Delete device events // Delete device events
$.ajax({ $.ajax({
method: "DELETE", method: "DELETE",
url: `${baseUrl}/device/${encodeURIComponent(mac)}/events/delete`, url: `${apiBase}/device/${encodeURIComponent(mac)}/events/delete`,
headers: { headers: {
"Authorization": "Bearer " + apiToken "Authorization": "Bearer " + apiToken
}, },
@@ -641,11 +634,12 @@
return; return;
} }
const baseUrl = getApiBase(); // Build base URL dynamically
const apiBase = getApiBase();
$.ajax({ $.ajax({
method: "POST", method: "POST",
url: `${baseUrl}/device/${encodeURIComponent(mac)}/reset-props`, url: `${apiBase}/device/${encodeURIComponent(mac)}/reset-props`,
dataType: "json", dataType: "json",
headers: { headers: {
"Authorization": "Bearer " + apiToken "Authorization": "Bearer " + apiToken
@@ -675,7 +669,7 @@
$.ajax({ $.ajax({
method: "GET", method: "GET",
url: `${protocol}//${host}:${port}/nettools/internetinfo`, url: `${apiBase}/nettools/internetinfo`,
headers: { headers: {
"Authorization": "Bearer " + apiToken, "Authorization": "Bearer " + apiToken,
"Content-Type": "application/json" "Content-Type": "application/json"