Add sandbox switch for dns made easy

This commit is contained in:
Fang-Pen Lin
2025-11-20 18:49:46 -08:00
parent b187cb9494
commit 0d721686e6
2 changed files with 13 additions and 1 deletions

View File

@@ -119,6 +119,7 @@ const envSchema = z
})
.default("{}")
),
DNS_MADE_EASY_SANDBOX_ENABLED: zodStrBool.default("false").optional(),
// smtp options
SMTP_HOST: zpStr(z.string().optional()),
SMTP_IGNORE_TLS: zodStrBool.default("false"),

View File

@@ -5,7 +5,9 @@ import { crypto } from "@app/lib/crypto/cryptography";
import { BadRequestError } from "@app/lib/errors";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
import https from "https";
import { getConfig } from "@app/lib/config/env";
import { DNSMadeEasyConnectionMethod } from "./dns-made-easy-connection-enum";
import {
TDNSMadeEasyConnection,
@@ -24,6 +26,11 @@ interface DNSMadeEasyApiResponse {
page: number;
}
const getDNSMadeEasyUrl = (path: string) => {
const appCfg = getConfig();
return `${appCfg.DNS_MADE_EASY_SANDBOX_ENABLED ? IntegrationUrls.DNS_MADE_EASY_SANDBOX_API_URL : IntegrationUrls.DNS_MADE_EASY_API_URL}${path}`;
};
export const makeDNSMadeEasyAuthHeaders = (
apiKey: string,
secretKey: string,
@@ -92,7 +99,11 @@ export const validateDNSMadeEasyConnectionCredentials = async (config: TDNSMadeE
const { apiKey, secretKey } = config.credentials;
try {
const resp = await request.get(`${IntegrationUrls.DNS_MADE_EASY_API_URL}/V2.0/dns/managed/`, {
const resp = await request.get(getDNSMadeEasyUrl("/V2.0/dns/managed/"), {
httpAgent: new https.Agent({
minVersion: "TLSv1.2",
maxVersion: "TLSv1.2"
}),
headers: {
...makeDNSMadeEasyAuthHeaders(apiKey, secretKey),
Accept: "application/json"