diff --git a/utopia-remix/.env.sample b/utopia-remix/.env.sample index 1c76d9fffdce..cba4e8152577 100644 --- a/utopia-remix/.env.sample +++ b/utopia-remix/.env.sample @@ -1,2 +1,3 @@ CORS_ORIGIN="http://localhost:8000" BACKEND_URL="http://localhost:8001" +SERVER_ENV="local" diff --git a/utopia-remix/app/env.server.ts b/utopia-remix/app/env.server.ts index dbedffc27105..6cf0687ea453 100644 --- a/utopia-remix/app/env.server.ts +++ b/utopia-remix/app/env.server.ts @@ -1,4 +1,13 @@ +declare global { + namespace NodeJS { + interface ProcessEnv { + SERVER_ENV?: "local" | "stage" | "prod" | "test"; + } + } +} + export const ServerEnvironment = { + environment: process.env.SERVER_ENV, // The URL of the actual backend server in the form ://: BackendURL: process.env.BACKEND_URL ?? "", // the CORS allowed origin for incoming requests diff --git a/utopia-remix/app/util/proxy.server.ts b/utopia-remix/app/util/proxy.server.ts index 6d65b84f8384..efc30a90c693 100644 --- a/utopia-remix/app/util/proxy.server.ts +++ b/utopia-remix/app/util/proxy.server.ts @@ -3,9 +3,11 @@ import { ServerEnvironment } from "../env.server"; import { proxiedResponse } from "./api.server"; import dns from "dns"; -// this is a workaround for default DNS resolution order with Node > 17 (where ipv6 is first) -// https://github.com/node-fetch/node-fetch/issues/1624#issuecomment-1235826631 -dns.setDefaultResultOrder("ipv4first"); +if (ServerEnvironment.environment === "local") { + // this is a workaround for default DNS resolution order with Node > 17 (where ipv6 comes first) + // https://github.com/node-fetch/node-fetch/issues/1624#issuecomment-1235826631 + dns.setDefaultResultOrder("ipv4first"); +} const BASE_URL = ServerEnvironment.BackendURL;