diff --git a/server/lib/config.ts b/server/lib/config.ts index b8e61617..7c5ad227 100644 --- a/server/lib/config.ts +++ b/server/lib/config.ts @@ -274,6 +274,7 @@ export class Config { ?.allow_base_domain_resources ? "true" : "false"; + process.env.DASHBOARD_URL = parsedConfig.data.app.dashboard_url; this.rawConfig = parsedConfig.data; } diff --git a/src/app/[orgId]/settings/sites/CreateSiteForm.tsx b/src/app/[orgId]/settings/sites/CreateSiteForm.tsx index 849c376f..72774fdd 100644 --- a/src/app/[orgId]/settings/sites/CreateSiteForm.tsx +++ b/src/app/[orgId]/settings/sites/CreateSiteForm.tsx @@ -75,6 +75,7 @@ export default function CreateSiteForm({ const { toast } = useToast(); const api = createApiClient(useEnvContext()); + const { env } = useEnvContext(); const [isLoading, setIsLoading] = useState(false); const [isChecked, setIsChecked] = useState(false); @@ -234,13 +235,7 @@ Endpoint = ${siteDefaults.endpoint}:${siteDefaults.listenPort} PersistentKeepalive = 5` : ""; - // am I at http or https? - let proto = "https:"; - // if (typeof window !== "undefined") { - // proto = window.location.protocol; - // } - - const newtConfig = `newt --id ${siteDefaults?.newtId} --secret ${siteDefaults?.newtSecret} --endpoint ${proto}//${siteDefaults?.endpoint}`; + const newtConfig = `newt --id ${siteDefaults?.newtId} --secret ${siteDefaults?.newtSecret} --endpoint ${env.app.dashboardUrl}`; return (
diff --git a/src/lib/pullEnv.ts b/src/lib/pullEnv.ts index e189db5f..7d46fd4a 100644 --- a/src/lib/pullEnv.ts +++ b/src/lib/pullEnv.ts @@ -13,7 +13,8 @@ export function pullEnv(): Env { }, app: { environment: process.env.ENVIRONMENT as string, - version: process.env.APP_VERSION as string + version: process.env.APP_VERSION as string, + dashboardUrl: process.env.DASHBOARD_URL as string, }, email: { emailEnabled: process.env.EMAIL_ENABLED === "true" ? true : false diff --git a/src/lib/types/env.ts b/src/lib/types/env.ts index 7080d460..8e25b63d 100644 --- a/src/lib/types/env.ts +++ b/src/lib/types/env.ts @@ -2,6 +2,7 @@ export type Env = { app: { environment: string; version: string; + dashboardUrl: string; }, server: { externalPort: string;