From 6f564b225923899d3ac39af5c42ecbd6c37a0a02 Mon Sep 17 00:00:00 2001 From: tinola Date: Wed, 1 Nov 2023 19:21:07 +0100 Subject: [PATCH 1/2] Update ztApi.ts - change default URL of the Local Zerotier URL I think address http://zerotier:9993 may be a bit misleading, especially for the standalone version installations. My proposition is to use by default (if not specified in .env file ZT_ADDR variable) http://127.0.0.1:9993 which should work everywhere. --- src/utils/ztApi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/ztApi.ts b/src/utils/ztApi.ts index 9492c59d..e3c2609d 100644 --- a/src/utils/ztApi.ts +++ b/src/utils/ztApi.ts @@ -38,7 +38,7 @@ if (os.platform() === "freebsd") { ZT_FILE = process.env.ZT_SECRET_FILE || `${ZT_FOLDER}/authtoken.secret`; } -const LOCAL_ZT_ADDR = process.env.ZT_ADDR || "http://zerotier:9993"; +const LOCAL_ZT_ADDR = process.env.ZT_ADDR || "http://127.0.0.1:9993"; const CENTRAL_ZT_ADDR = "https://api.zerotier.com/api/v1"; let ZT_SECRET = process.env.ZT_SECRET; From 4bb3d46a1870da4ec7348c7926cfd61b0683e9c3 Mon Sep 17 00:00:00 2001 From: tinola Date: Wed, 1 Nov 2023 20:23:14 +0100 Subject: [PATCH 2/2] Update ztApi.ts When not docker enviroment use http://127.0.0.1:9993 else http://zerotier:9993 --- src/utils/ztApi.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/ztApi.ts b/src/utils/ztApi.ts index e3c2609d..0c431e16 100644 --- a/src/utils/ztApi.ts +++ b/src/utils/ztApi.ts @@ -26,6 +26,7 @@ import { type NetworkAndMemberResponse } from "~/types/network"; import { UserContext } from "~/types/ctx"; import os from "os"; import { prisma } from "~/server/db"; +import { isRunningInDocker } from "./docker"; export let ZT_FOLDER: string; export let ZT_FILE: string; @@ -38,7 +39,11 @@ if (os.platform() === "freebsd") { ZT_FILE = process.env.ZT_SECRET_FILE || `${ZT_FOLDER}/authtoken.secret`; } -const LOCAL_ZT_ADDR = process.env.ZT_ADDR || "http://127.0.0.1:9993"; +const LOCAL_ZT_ADDR = + process.env.ZT_ADDR || isRunningInDocker() + ? "http://zerotier:9993" + : "http://127.0.0.1:9993"; + const CENTRAL_ZT_ADDR = "https://api.zerotier.com/api/v1"; let ZT_SECRET = process.env.ZT_SECRET;