Skip to content

Commit

Permalink
fix(relay-dashboard): use domain for client side requests
Browse files Browse the repository at this point in the history
  • Loading branch information
blombern authored and alextes committed Sep 30, 2023
1 parent d417301 commit 2d7decc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/relay/components/CheckRegistrationWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const CheckRegistrationWidget: FC = () => {
const [registrationStatus, setRegistrationStatus] =
useState<Status>("initial");

const apiUrl = getDomain();
const apiUrl = getDomain(true);

const fetchRegistrationStatus = () => {
if (addr.length > 0) {
Expand Down
8 changes: 5 additions & 3 deletions src/relay/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ import * as SharedConfig from "../config";
// Inside the cluster, we need to use the k8s service name to call the api.
// Outside the cluster, e.g. during build, we need to use the domain name.

export const getDomain = () => {
export const getDomain = (isClientSide: boolean = false) => {
const apiEnv = SharedConfig.apiEnvFromEnv();
const isBuild = process.env.BUILD === "true";

switch (apiEnv) {
case "dev":
return "http://relay.localhost:3000";
case "stag":
return isBuild
return isBuild || isClientSide
? "https://relay-stag.ultrasound.money"
: "http://website-api";
case "prod":
return isBuild ? "https://relay.ultrasound.money" : "http://website-api";
return isBuild || isClientSide
? "https://relay.ultrasound.money"
: "http://website-api";
}
};

Expand Down

0 comments on commit 2d7decc

Please sign in to comment.