diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..fa29cdff --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +** \ No newline at end of file diff --git a/src/.env b/src/.env new file mode 100644 index 00000000..122fe628 --- /dev/null +++ b/src/.env @@ -0,0 +1,3 @@ +WG_HOST=127.0.0.1 +UI_TRAFFIC_STATS=true +UI_CHART_TYPE=2 \ No newline at end of file diff --git a/src/.eslintrc.json b/src/.eslintrc.json index 613dd7d5..20286524 100644 --- a/src/.eslintrc.json +++ b/src/.eslintrc.json @@ -6,6 +6,7 @@ "rules": { "consistent-return": "off", "no-shadow": "off", - "max-len": "off" + "max-len": "off", + "linebreak-style": "off" } } diff --git a/src/config.js b/src/config.js index 40b70ddf..a67b7bf4 100644 --- a/src/config.js +++ b/src/config.js @@ -1,6 +1,7 @@ 'use strict'; const { release } = require('./package.json'); +require('dotenv').config(); // development module.exports.RELEASE = release; module.exports.PORT = process.env.PORT || '51821'; diff --git a/src/package-lock.json b/src/package-lock.json index 2862da04..14822b5f 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -1337,6 +1337,17 @@ "node": ">=6.0.0" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", diff --git a/webui/src/services/api.js b/webui/src/services/api.js index 5fa82485..8de1cd34 100644 --- a/webui/src/services/api.js +++ b/webui/src/services/api.js @@ -1,6 +1,8 @@ +const SERVER = 'http://127.0.0.1:51821' + export default class API { async call({ method, path, body }) { - const res = await fetch(`./api${path}`, { + const res = await fetch(`${SERVER}/api${path}`, { method, headers: { 'Content-Type': 'application/json', @@ -11,7 +13,8 @@ export default class API { if (res.status === 204) { return undefined; } - + console.log(`${SERVER}/api${path}`); + const json = await res.json(); if (!res.ok) {