mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2024-11-08 02:30:09 -08:00
23 lines
580 B
JavaScript
23 lines
580 B
JavaScript
import axios from "axios";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
|
|
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 if (os.platform() === "linux") {
|
|
token = fs.readFileSync("/var/lib/zerotier-one/authtoken.secret", "utf8");
|
|
} else {
|
|
throw new Error("Please provide ZU_CONTROLLER_TOKEN in environment");
|
|
}
|
|
|
|
export const api = axios.create({
|
|
baseURL: baseURL,
|
|
responseType: "json",
|
|
headers: {
|
|
"X-ZT1-Auth": token,
|
|
},
|
|
});
|