File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { headers as nextHeaders } from "next/headers";
55import { AuthError } from "./errors" ;
66
77const API_PREFIX = normalizePrefix ( process . env . NEXT_PUBLIC_API_BASE ?? "/api" ) ;
8+ const API_BASE_URL = ( process . env . NEXT_PUBLIC_API_URL || "" ) . trim ( ) . replace ( / \/ + $ / , "" ) ;
89const ENV_SITE_URL = ensureOrigin ( process . env . NEXT_PUBLIC_SITE_URL ) ;
910
1011const devHttpsAgent =
@@ -41,10 +42,12 @@ export async function createAxiosServer(opts?: {
4142} ) : Promise < AxiosInstance > {
4243 // 쿠키 전달 (SSR 세션 유지용)
4344 const h = await nextHeaders ( ) ;
44- // env 우선 , 없으면 요청 헤더 기반 origin 사용
45+ // API URL이 있으면 직접 사용 , 없으면 요청 헤더 기반으로 /api 프록시 사용
4546 const siteOrigin =
4647 ENV_SITE_URL || originFromHeaders ( h ) || "https://localhost:3000" ;
47- const baseURL = new URL ( API_PREFIX , siteOrigin ) . toString ( ) ;
48+ const baseURL = API_BASE_URL
49+ ? API_BASE_URL
50+ : new URL ( API_PREFIX , siteOrigin ) . toString ( ) ;
4851 const cookie = opts ?. forwardCookies === false ? "" : ( h . get ( "cookie" ) ?? "" ) ;
4952
5053 const instance = axios . create ( {
You can’t perform that action at this time.
0 commit comments