zero-ui/backend/utils/controller-api.js
2021-03-21 22:25:13 +03:00

19 lines
445 B
JavaScript

const axios = require("axios");
const fs = require("fs");
const baseURL = process.env.ZU_CONTROLLER_ENDPOINT || "http://localhost:9993/";
var token;
if (process.env.ZU_CONTROLLER_TOKEN) {
token = process.env.ZU_CONTROLLER_TOKEN;
} else {
token = fs.readFileSync("/var/lib/zerotier-one/authtoken.secret", "utf8");
}
module.exports = axios.create({
baseURL: baseURL,
responseType: "json",
headers: {
"X-ZT1-Auth": token,
},
});