Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set ipv4 resolution only for local dev #4837

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions utopia-remix/.env.sample
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
CORS_ORIGIN="http://localhost:8000"
BACKEND_URL="http://localhost:8001"
SERVER_ENV="local"
9 changes: 9 additions & 0 deletions utopia-remix/app/env.server.ts
Original file line number Diff line number Diff line change
@@ -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 <scheme>://<host>:<port>
BackendURL: process.env.BACKEND_URL ?? "",
// the CORS allowed origin for incoming requests
Expand Down
8 changes: 5 additions & 3 deletions utopia-remix/app/util/proxy.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading