Skip to content

Commit eef713f

Browse files
committed
fixup
1 parent 1d61180 commit eef713f

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
export const getBaseUrl = (isProd) => {
2-
const port = process.env.PORT || 5173;
3-
return process.env.BASE || (isProd ? "/front_6th_chapter4-1/vanilla/" : `http://localhost:${port}/`);
2+
// Node 환경 (process.env 있음)
3+
const nodeEnv = typeof process !== "undefined" ? process.env : {};
4+
5+
// Browser 환경 (import.meta.env 있음)
6+
const browserEnv = typeof import.meta !== "undefined" ? import.meta.env : {};
7+
8+
if (typeof window !== "undefined") {
9+
// 브라우저 환경
10+
if (isProd) {
11+
// gh-pages 같은 정적 배포
12+
return browserEnv.VITE_BASE || "/front_6th_chapter4-1/vanilla/";
13+
} else {
14+
// 개발 환경 → origin만 사용
15+
16+
return window.location.origin + "/";
17+
}
18+
}
19+
20+
// Node 환경 (서버에서 실행될 때)
21+
const port = nodeEnv.PORT || 5173;
22+
return nodeEnv.BASE || (isProd ? "/front_6th_chapter4-1/vanilla/" : `http://localhost:${port}/`);
423
};

0 commit comments

Comments
 (0)