File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
packages/vanilla/src/mocks Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change 11export 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} ;
You can’t perform that action at this time.
0 commit comments