Skip to content

Commit 5fc62cd

Browse files
committed
chore(config): update api origin definitions
1 parent b0da6bb commit 5fc62cd

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

config/api-origin.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export declare const normalizeOrigin: (origin?: string) => string;
2-
export declare const DEFAULT_API_ORIGIN: string;
2+
export declare const INTERNAL_API_ORIGIN: string;
3+
export declare const PUBLIC_API_ORIGIN: string;
34
export declare const API_ORIGIN: string;

config/api-origin.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
const normalizeOrigin = (origin) => (origin ?? "").replace(/\/+$/, "");
22

3-
const DEFAULT_API_ORIGIN = normalizeOrigin("http://128.0.0.255:8080");
4-
const API_ORIGIN = DEFAULT_API_ORIGIN;
3+
const INTERNAL_API_ORIGIN = normalizeOrigin("http://128.0.0.255:8080");
4+
const PUBLIC_API_ORIGIN = normalizeOrigin("https://cmnw.me");
5+
6+
const isServerRuntime = () => typeof window === "undefined";
7+
8+
const API_ORIGIN = isServerRuntime() ? INTERNAL_API_ORIGIN : PUBLIC_API_ORIGIN;
59

610
module.exports = {
711
API_ORIGIN,
8-
DEFAULT_API_ORIGIN,
12+
INTERNAL_API_ORIGIN,
13+
PUBLIC_API_ORIGIN,
914
normalizeOrigin,
1015
};

0 commit comments

Comments
 (0)