Skip to content

refactor: NEXT_PUBLIC_HOST 환경변수 제거 및 동적 호스트 대체 #93

Closed

Description

@egoing

목표

NEXT_PUBLIC_HOST 환경변수를 제거하고, 서버/클라이언트에서 동적으로 호스트 URL을 얻도록 변경합니다.

Blocks #80

배경

조사 결과 모든 사용처에서 동적 대체가 가능합니다 (난이도 낮음).

작업

사용처별 대체 방안

파일 대안
app/share/[id]/page.tsx (await headers()).get('host') (이미 같은 파일에서 사용 중)
app/robots.ts (await headers()).get('host') + async 변환
app/sitemap.ts (await headers()).get('host') + async 변환
app/api/sync/push/route.ts 해당 검증 라인 삭제 (값을 실제 사용하지 않음)
app/share/[id]/SharePageContent.tsx 상대 경로 /welcome 사용
app/(ui)/(welcome)/welcome/page.tsx window.location.origin
supabase/config.toml http://localhost:3000 하드코딩 (로컬 전용)
테스트 파일들 http://localhost:3000 하드코딩 또는 제거

서버 사이드 공통 유틸리티 추출

// src/functions/utils/getAppUrl.ts
import { headers } from 'next/headers';
export async function getAppUrl(): Promise<string> {
    const host = (await headers()).get('host');
    if (!host) return 'https://otu.ai';
    const protocol = host.includes('localhost') ? 'http' : 'https';
    return `${protocol}://${host}`;
}

.env.template, 문서에서 NEXT_PUBLIC_HOST 관련 항목 제거

참고

  • robots.ts, sitemap.ts에 headers() 도입 시 정적 → 동적 렌더링으로 전환됨 (성능 영향 미미)
  • Login.tsx는 이미 window.location.origin 우선 사용 패턴 구현되어 있음 (참고용)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions