diff --git a/server.js b/server.js index 9fc826a..e547beb 100644 --- a/server.js +++ b/server.js @@ -120,7 +120,7 @@ app.post("/videos/restart", async (req, res) => { var options = { method: "GET", - url: `http://${process.env.VIRTUAL_HOST}/http/restart`, + url: `/http/restart`, headers: { "Content-Type": "application/json" }, data: { video: true }, }; @@ -2756,7 +2756,7 @@ app.post("/update-group", async (req, res) => { async function getParameters(serial) { const requestResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`, + `/http/parameters/request?serial=${serial}`, { headers: { "Content-Type": "application/json", @@ -2770,7 +2770,7 @@ async function getParameters(serial) { await new Promise((resolve) => setTimeout(resolve, 300)); const requestResponse2 = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`, + `/http/parameters/request?serial=${serial}`, { headers: { "Content-Type": "application/json", @@ -2784,7 +2784,7 @@ async function getParameters(serial) { await new Promise((resolve) => setTimeout(resolve, 300)); const requestResponse3 = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`, + `/http/parameters/request?serial=${serial}`, { headers: { "Content-Type": "application/json", @@ -2798,7 +2798,7 @@ async function getParameters(serial) { await new Promise((resolve) => setTimeout(resolve, 300)); const requestResponse5 = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`, + `/http/parameters/request?serial=${serial}`, { headers: { "Content-Type": "application/json", @@ -2809,12 +2809,10 @@ async function getParameters(serial) { } ); - // console.log(requestResponse.data); + console.log(requestResponse.data); await new Promise((resolve) => setTimeout(resolve, 300)); - const getResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}` - ); + const getResponse = await axios.get(`/http/parameters/get?serial=${serial}`); return getResponse.data; } @@ -2833,7 +2831,7 @@ app.post("/main-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const requestResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`, + `/http/parameters/request?serial=${serial}`, { headers: { "Content-Type": "application/json", @@ -2847,7 +2845,7 @@ app.post("/main-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const getResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}` + `/http/parameters/get?serial=${serial}` ); res.json(getResponse.data); @@ -2888,15 +2886,12 @@ app.put("/main-parameters", async (req, res) => { .status(400) .send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); } - const response = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`, - { - data: JSON.stringify(requestBody), - headers: { - "Content-Type": "application/json", - }, - } - ); + const response = await axios.get(`/http/parameters/set?serial=${serial}`, { + data: JSON.stringify(requestBody), + headers: { + "Content-Type": "application/json", + }, + }); res.status(response.status).send(response.data); } catch (error) { res.status(500).send("Произошла ошибка при отправке GET запроса."); @@ -2939,7 +2934,7 @@ app.post("/ethernet-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const requestResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`, + `/http/parameters/request?serial=${serial}`, { headers: { "Content-Type": "application/json", @@ -2953,7 +2948,7 @@ app.post("/ethernet-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const getResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}` + `/http/parameters/get?serial=${serial}` ); res.json(getResponse.data); @@ -3004,15 +2999,12 @@ app.put("/ethernet-parameters", async (req, res) => { .status(400) .send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); } - const response = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`, - { - data: JSON.stringify(requestBody), - headers: { - "Content-Type": "application/json", - }, - } - ); + const response = await axios.get(`/http/parameters/set?serial=${serial}`, { + data: JSON.stringify(requestBody), + headers: { + "Content-Type": "application/json", + }, + }); res.status(response.status).send(response.data); } catch (error) { res.status(500).send("Произошла ошибка при отправке GET запроса."); @@ -3033,7 +3025,7 @@ app.post("/wifi-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const requestResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`, + `/http/parameters/request?serial=${serial}`, { headers: { "Content-Type": "application/json", @@ -3047,7 +3039,7 @@ app.post("/wifi-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const getResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}` + `/http/parameters/get?serial=${serial}` ); res.json(getResponse.data); @@ -3094,15 +3086,12 @@ app.put("/wifi-parameters", async (req, res) => { .status(400) .send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); } - const response = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`, - { - data: JSON.stringify(requestBody), - headers: { - "Content-Type": "application/json", - }, - } - ); + const response = await axios.get(`/http/parameters/set?serial=${serial}`, { + data: JSON.stringify(requestBody), + headers: { + "Content-Type": "application/json", + }, + }); res.status(response.status).send(response.data); } catch (error) { res.status(500).send("Произошла ошибка при отправке GET запроса."); @@ -3123,7 +3112,7 @@ app.post("/communication-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const requestResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`, + `/http/parameters/request?serial=${serial}`, { headers: { "Content-Type": "application/json", @@ -3137,7 +3126,7 @@ app.post("/communication-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const getResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}` + `/http/parameters/get?serial=${serial}` ); res.json(getResponse.data); @@ -3193,15 +3182,12 @@ app.put("/communication-parameters", async (req, res) => { .status(400) .send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); } - const response = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`, - { - data: JSON.stringify(requestBody), - headers: { - "Content-Type": "application/json", - }, - } - ); + const response = await axios.get(`/http/parameters/set?serial=${serial}`, { + data: JSON.stringify(requestBody), + headers: { + "Content-Type": "application/json", + }, + }); res.status(response.status).send(response.data); } catch (error) { res.status(500).send("Произошла ошибка при отправке GET запроса."); @@ -3222,7 +3208,7 @@ app.post("/install-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const requestResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`, + `/http/parameters/request?serial=${serial}`, { headers: { "Content-Type": "application/json", @@ -3236,7 +3222,7 @@ app.post("/install-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const getResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}` + `/http/parameters/get?serial=${serial}` ); res.json(getResponse.data); @@ -3260,7 +3246,7 @@ app.post("/ai-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const requestResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`, + `/http/parameters/request?serial=${serial}`, { headers: { "Content-Type": "application/json", @@ -3274,7 +3260,7 @@ app.post("/ai-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const getResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}` + `/http/parameters/get?serial=${serial}` ); res.json(getResponse.data); @@ -3314,15 +3300,12 @@ app.put("/ai-parameters", async (req, res) => { .status(400) .send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); } - const response = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`, - { - data: JSON.stringify(requestBody), - headers: { - "Content-Type": "application/json", - }, - } - ); + const response = await axios.get(`/http/parameters/set?serial=${serial}`, { + data: JSON.stringify(requestBody), + headers: { + "Content-Type": "application/json", + }, + }); res.status(response.status).send(response.data); } catch (error) { res.status(500).send("Произошла ошибка при отправке GET запроса."); @@ -3343,7 +3326,7 @@ app.post("/cameras-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const requestResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/request?serial=${serial}`, + `/http/parameters/request?serial=${serial}`, { headers: { "Content-Type": "application/json", @@ -3357,7 +3340,7 @@ app.post("/cameras-parameters", async (req, res) => { await new Promise((resolve) => setTimeout(resolve, 1000)); const getResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/get?serial=${serial}` + `/http/parameters/get?serial=${serial}` ); res.json(getResponse.data); @@ -3393,15 +3376,12 @@ app.put("/cameras-parameters", async (req, res) => { .status(400) .send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); } - const response = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`, - { - data: JSON.stringify(requestBody), - headers: { - "Content-Type": "application/json", - }, - } - ); + const response = await axios.get(`/http/parameters/set?serial=${serial}`, { + data: JSON.stringify(requestBody), + headers: { + "Content-Type": "application/json", + }, + }); res.status(response.status).send(response.data); } catch (error) { res.status(500).send("Произошла ошибка при отправке GET запроса."); @@ -3437,15 +3417,12 @@ app.put("/install-parameters", async (req, res) => { .status(400) .send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); } - const response = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`, - { - data: JSON.stringify(requestBody), - headers: { - "Content-Type": "application/json", - }, - } - ); + const response = await axios.get(`/http/parameters/set?serial=${serial}`, { + data: JSON.stringify(requestBody), + headers: { + "Content-Type": "application/json", + }, + }); res.status(response.status).send(response.data); } catch (error) { res.status(500).send("Произошла ошибка при отправке GET запроса."); @@ -3835,15 +3812,12 @@ app.put("/device-parameters", async (req, res) => { .status(400) .send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); } - const response = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`, - { - data: JSON.stringify(requestBody), - headers: { - "Content-Type": "application/json", - }, - } - ); + const response = await axios.get(`/http/parameters/set?serial=${serial}`, { + data: JSON.stringify(requestBody), + headers: { + "Content-Type": "application/json", + }, + }); res.status(response.status).send(response.data); } catch (error) { res.status(500).send("Произошла ошибка при отправке GET запроса."); @@ -3876,15 +3850,12 @@ app.put("/camera-parameters", async (req, res) => { .status(400) .send("Ошибка: lastkeepalive старше минуты или устройство не найдено."); } - const response = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/parameters/set?serial=${serial}`, - { - data: JSON.stringify(requestBody), - headers: { - "Content-Type": "application/json", - }, - } - ); + const response = await axios.get(`/http/parameters/set?serial=${serial}`, { + data: JSON.stringify(requestBody), + headers: { + "Content-Type": "application/json", + }, + }); res.status(response.status).send(response.data); } catch (error) { res.status(500).send("Произошла ошибка при отправке GET запроса."); @@ -5081,12 +5052,12 @@ app.get("/getData", async (req, res) => { try { const successResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/filelist/request?serial=${selectedSerial}&querytime=${selectedDate}&channel=${selectedChannel}` + `/http/filelist/request?serial=${selectedSerial}&querytime=${selectedDate}&channel=${selectedChannel}` ); if (successResponse.data.SUCCESS) { await new Promise((resolve) => setTimeout(resolve, 7000)); const dataResponse = await axios.get( - `http://${process.env.VIRTUAL_HOST}/http/filelist/get?serial=${selectedSerial}&querytime=${selectedDate}&channel=${selectedChannel}` + `/http/filelist/get?serial=${selectedSerial}&querytime=${selectedDate}&channel=${selectedChannel}` ); if (successResponse.data.SUCCESS) { const dataId = dataResponse.data.DATAID;