Skip to content

Commit f4e68d7

Browse files
committed
fix: 환경별 Base URL 구성이 올바르게 되지 않던 문제 해결
1 parent 22b6e31 commit f4e68d7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/shared/api/config.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
export function getBaseUrl() {
2-
if (process.env.VERCEL === "1") {
3-
return `https://${process.env.VERCEL_URL}`;
4-
}
1+
import { headers } from "next/headers";
52

6-
return "http://localhost:3000";
3+
export async function getBaseUrl() {
4+
const h = await headers();
5+
const host = h.get("host");
6+
7+
const protocol =
8+
host?.includes("localhost") || process.env.NODE_ENV === "development"
9+
? "http"
10+
: "https";
11+
12+
return `${protocol}://${host}`;
713
}

0 commit comments

Comments
 (0)